File: ugtkhello.py

package info (click to toggle)
far2l 2.7.0~beta%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 44,304 kB
  • sloc: cpp: 263,566; ansic: 53,886; python: 7,048; sh: 1,516; perl: 410; javascript: 279; xml: 145; makefile: 31
file content (43 lines) | stat: -rw-r--r-- 1,000 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import threading
from far2l.plugin import PluginBase

import gi

gi.require_version("Gtk", "3.0")
from gi.repository import Gtk


import logging
log = logging.getLogger(__name__)

class MyWindow(Gtk.Window):
    def __init__(self):
        super().__init__(title="Hello World")

        self.button = Gtk.Button(label="Click Here")
        self.button.connect("clicked", self.on_button_clicked)
        self.add(self.button)

        self.connect("destroy", self.onQuit)
        self.show_all()

    def on_button_clicked(self, widget):
        log.debug("Hello World")

    def onQuit(self, window):
        Gtk.main_quit()

class Plugin(PluginBase):
    label = "Python GTK"
    openFrom = ["PLUGINSMENU", "EDITOR"]

    def OpenPlugin(self, OpenFrom):
        if OpenFrom == 5:
            # EDITOR
            def proc():
                win = MyWindow()
                Gtk.main()
            t = threading.Thread(target=proc)
            t.daemon = True
            t.start()
        return -1