2

这是我的应用程序的代码

从 lib.HTMLWindow 导入 HTMLWindow 从 gi.repository 导入 Gtk

类我的窗口(HTMLWindow):

def __init__(self):
    super(MyWindow, self).__init__(442, 442)
    self.drag = True
    self.connect('button-press-event', self.button_press)

def button_press(self, widget, event):
    if event.button == 1 and self.drag:
        print "button 1 pressed and self drag is true"
        Gtk.Window.begin_move_drag(self, event.button, event.x_root, event.y_root, event.time)

def on_html_message(self, signal_name, data):
    print "signal received from frontend: %(signal)s, with this data: %(data)s" % {'signal': signal_name, 'data': data}

    if signal_name == 'frontend_loaded':
        version = 'Unknown OS'
        for line in open('/etc/lsb-release'):
            if 'DISTRIB_DESCRIPTION' in line:
                version = line.replace('DISTRIB_DESCRIPTION=', '')[1:-2]
        self.send_html_message('version_provided', {"version": "%s %s" % (data, version)})

    elif signal_name == 'quit':
        self.destroy()

    elif signal_name == 'minimize':
        self.iconify()

    elif signal_name == 'enable_drag':
        self.drag = True

    elif signal_name == 'disable_drag':
        self.drag = False
4

0 回答 0