sonist-gtk/usr/lib/sonist/ui/topbar.py

38 lines
844 B
Python

#!/usr/bin/env python3
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk
from .image_button import ImageButton
from .option_menu import OptionMenu
from assets import image_dict
class Topbar(Gtk.EventBox):
def __init__(self, app, win):
Gtk.EventBox.__init__(self)
self.window = win
self.set_size_request(320, 26)
box = Gtk.Fixed()
menu_btn = ImageButton(image_dict['menu'])
popup_menu = OptionMenu(app)
menu_btn.connect('clicked', lambda btn: popup_menu.show(btn))
box.put(menu_btn, 276, 6)
self.connect("button-press-event", self.on_drag)
self.add(box)
def on_drag(self, widget, event):
if event.button == Gdk.BUTTON_PRIMARY:
self.window.begin_move_drag(
event.button,
int(event.x_root),
int(event.y_root),
event.time)
python + gtk3开发的基于mpd后端的音乐播放器
Python 99.1%
Shell 0.9%