Python gi.repository.Gtk.main() Examples

The following are 30 code examples of gi.repository.Gtk.main(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module gi.repository.Gtk , or try the search function .
Example #1
Source File: gtk.py    From pychess with GNU General Public License v3.0 6 votes vote down vote up
def run(self):
        """Run the event loop until Gtk.main_quit is called.

        May be called multiple times to recursively start it again. This
        is useful for implementing asynchronous-like dialogs in code that
        is otherwise not asynchronous, for example modal dialogs.
        """
        if self.is_running():
            with self._recurselock:
                self._recursive += 1
            try:
                Gtk.main()
            finally:
                with self._recurselock:
                    self._recursive -= 1
        else:
            super().run() 
Example #2
Source File: asktext.py    From textext with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def ask(self, callback, preview_callback=None):
        with warnings.catch_warnings():
            warnings.filterwarnings("ignore", module="asktext")
            warnings.filterwarnings("ignore", category=DeprecationWarning)
            self.callback = callback
            self._preview_callback = preview_callback

            # create first window
            with SuppressStream():  # suppress GTK Warings printed directly to stderr in C++
                window = self.create_window()
            window.set_default_size(500, 500)
            # Until commit 802d295e46877fd58842b61dbea4276372a2505d we called own normalize_ui_row_heights here with
            # bad hide/show/hide hack, see issue #114
            window.show()
            self._window = window
            self._window.set_focus(self._source_view)

            # main loop
            Gtk.main()
            return self._gui_config 
Example #3
Source File: message.py    From epoptes with GNU General Public License v3.0 6 votes vote down vote up
def main():
    """Run the module from the command line."""
    if len(sys.argv) <= 1 or len(sys.argv) > 5:
        print(_("Usage: {} text [title] [markup] [icon_name]").format(
            os.path.basename(__file__)), file=sys.stderr)
        exit(1)
    text = sys.argv[1]
    if len(sys.argv) > 2 and sys.argv[2]:
        title = sys.argv[2]
    else:
        title = "Epoptes"
    if len(sys.argv) > 3 and sys.argv[3]:
        markup = sys.argv[3].lower() == "true"
    else:
        markup = True
    if len(sys.argv) > 4:
        icon_name = sys.argv[4]
    else:
        icon_name = "dialog-information"

    window = MessageWindow(text, title, markup, icon_name)
    window.connect("destroy", Gtk.main_quit)
    window.show_all()
    Gtk.main() 
Example #4
Source File: start.py    From RAFCON with Eclipse Public License 1.0 5 votes vote down vote up
def start_gtk():
    # check if twisted is imported
    if reactor_required():
        from twisted.internet import reactor
        import threading
        is_main_thread = isinstance(threading.current_thread(), threading._MainThread)
        reactor.run(installSignalHandlers=is_main_thread)
    else:
        Gtk.main() 
Example #5
Source File: dbusservice.py    From deskcon-desktop with GNU General Public License v3.0 5 votes vote down vote up
def run(self):
        DBusGMainLoop(set_as_default=True)        
        GObject.threads_init()
        dbus.mainloop.glib.threads_init()
        self.dbusservice = self.DbusService(self.connector)        
        Gtk.main() 
Example #6
Source File: kickoff_player.py    From kickoff-player with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
    GLib.set_prgname('kickoff-player')
    GLib.set_application_name('Kickoff Player')

    add_custom_css('ui/styles.css')

    self.argparse = argparse.ArgumentParser(prog='kickoff-player')
    self.argparse.add_argument('url', metavar='URL', nargs='?', default=None)

    self.cache = CacheHandler()
    self.data  = DataHandler()

    self.scores_api  = ScoresApi(self.data, self.cache)
    self.streams_api = StreamsApi(self.data, self.cache)

    self.main = Gtk.Builder()
    self.main.add_from_file(relative_path('ui/main.ui'))
    self.main.connect_signals(self)

    self.window        = self.main.get_object('window_main')
    self.header_back   = self.main.get_object('header_button_back')
    self.header_reload = self.main.get_object('header_button_reload')
    self.main_stack    = self.main.get_object('stack_main')

    self.player_stack   = self.main.get_object('stack_player')
    self.matches_stack  = self.main.get_object('stack_matches')
    self.channels_stack = self.main.get_object('stack_channels')

    self.matches  = MatchHandler(self)
    self.channels = ChannelHandler(self)
    self.player   = PlayerHandler(self)

    GLib.timeout_add(2000, self.toggle_reload, True)
    self.open_stream_url() 
Example #7
Source File: kickoff_player.py    From kickoff-player with GNU General Public License v3.0 5 votes vote down vote up
def run(self):
    self.window.show_all()
    Gtk.main() 
Example #8
Source File: __main__.py    From pyWinUSB with MIT License 5 votes vote down vote up
def main():
    if not check_root_access():
        sys.exit("\nOnly root can run this script :(\n")

    win = AppWindow()
    win.show_all()

    Gdk.threads_enter()
    GObject.threads_init()
    Gtk.main()
    Gdk.threads_leave() 
Example #9
Source File: PyChessFICS.py    From pychess with GNU General Public License v3.0 5 votes vote down vote up
def run(self):
        t = Thread(target=self.main, name=fident(self.main))
        t.daemon = True
        t.start()
        Gdk.threads_init()
        Gtk.main()

    # General 
Example #10
Source File: start.py    From RAFCON with Eclipse Public License 1.0 5 votes vote down vote up
def setup_gui():
    from rafcon.gui.controllers.main_window import MainWindowController
    from rafcon.gui.views.main_window import MainWindowView

    # Create the GUI-View
    main_window_view = MainWindowView()

    # set the gravity of the main window controller to static to ignore window manager decorations and get
    # a correct position of the main window on the screen (else there are offsets for some window managers)
    main_window_view.get_top_widget().set_gravity(Gdk.Gravity.STATIC)

    sm_manager_model = gui_singletons.state_machine_manager_model
    main_window_controller = MainWindowController(sm_manager_model, main_window_view)
    return main_window_controller 
Example #11
Source File: sms.py    From deskcon-desktop with GNU General Public License v3.0 5 votes vote down vote up
def main(args):
    GObject.threads_init()
    ip = args[1]
    port = args[2]
    if (len(args) == 4):       
        number = args[3]
    else:
        number = ""

    win = EntryWindow(ip, port, number)
    Gtk.main() 
Example #12
Source File: start.py    From RAFCON with Eclipse Public License 1.0 5 votes vote down vote up
def stop_gtk():
    # shutdown twisted correctly
    if reactor_required():
        from twisted.internet import reactor
        if reactor.running:
            reactor.callFromThread(reactor.stop)
        # Twisted can be imported without the reactor being used
        # => check if GTK main loop is running
        elif Gtk.main_level() > 0:
            GLib.idle_add(Gtk.main_quit)
    else:
        GLib.idle_add(Gtk.main_quit)

    # Run the GTK loop until no more events are being generated and thus the GUI is fully destroyed
    wait_for_gui() 
Example #13
Source File: slideshow_test.py    From vimiv with MIT License 5 votes vote down vote up
def refresh_gui(vimiv=None):
    """Refresh the GUI as the Gtk.main() loop is not running when testing.

    Args:
        vimiv: Vimiv class to receive slideshow index.
    """
    current_pos = vimiv.get_index()
    while current_pos == vimiv.get_index():
        Gtk.main_iteration_do(False) 
Example #14
Source File: PyChessFICS.py    From pychess with GNU General Public License v3.0 5 votes vote down vote up
def main(self):
        self.connection.run()
        self.extendlog([str(self.acceptedTimesettings)])
        self.phoneHome("Session ended\n" + "\n".join(self.log))
        print("Session ended") 
Example #15
Source File: vimiv_testcase.py    From vimiv with MIT License 5 votes vote down vote up
def refresh_gui(delay=0):
    """Refresh the GUI as the Gtk.main() loop is not running when testing.

    Args:
        delay: Time to wait before refreshing.
    """
    time.sleep(delay)
    while Gtk.events_pending():
        Gtk.main_iteration_do(False) 
Example #16
Source File: __main__.py    From volctl with GNU General Public License v2.0 5 votes vote down vote up
def main():
    """Start volctl."""
    import gi

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

    VolctlApp()
    Gtk.main() 
Example #17
Source File: gui.py    From pysmt with Apache License 2.0 5 votes vote down vote up
def main():
    size = 3
    if len(sys.argv) > 1:
        try:
            size = int(sys.argv[1])
        except ValueError:
            print "Unknown number %s" % sys.argv[1]
            print "Usage: %s [number of tiles]" % sys.argv[0]
            exit(1)

    win = GridWindow(size)
    win.connect("delete-event", Gtk.main_quit)
    win.show_all()
    Gtk.main() 
Example #18
Source File: setupdevice.py    From deskcon-desktop with GNU General Public License v3.0 5 votes vote down vote up
def main(args):
    GObject.threads_init()
    win = EntryWindow()
    Gtk.main() 
Example #19
Source File: backend_gtk3.py    From neural-network-animation with MIT License 5 votes vote down vote up
def mainloop(self):
        if Gtk.main_level() == 0:
            Gtk.main() 
Example #20
Source File: windows.py    From deskcon-desktop with GNU General Public License v3.0 5 votes vote down vote up
def start(self):        
        self.connect("destroy", Gtk.main_quit)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.show_all()
        GObject.threads_init()
        Gtk.main()
        return self.accepted 
Example #21
Source File: fingerprints.py    From deskcon-desktop with GNU General Public License v3.0 5 votes vote down vote up
def main(args):
    myfp = args[1]
    devicefp = args[2]
    pairing = PairingWindow(myfp, devicefp)
    choice = pairing.start()
    print choice 
Example #22
Source File: fingerprints.py    From deskcon-desktop with GNU General Public License v3.0 5 votes vote down vote up
def start(self):        
        self.connect("destroy", Gtk.main_quit)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.show_all()
        GObject.threads_init()
        Gtk.main()
        return self.accepted 
Example #23
Source File: notificationmanager.py    From deskcon-desktop with GNU General Public License v3.0 5 votes vote down vote up
def run(self):
        GObject.threads_init()
        self.sms_notification.show()
        Gtk.main() 
Example #24
Source File: notificationmanager.py    From deskcon-desktop with GNU General Public License v3.0 5 votes vote down vote up
def run(self):
        GObject.threads_init()
        self.nnotification.show()
        Gtk.main() 
Example #25
Source File: notificationmanager.py    From deskcon-desktop with GNU General Public License v3.0 5 votes vote down vote up
def run(self):
        GObject.threads_init()
        self.file_notification.show()

        timeout_thread = threading.Thread(target=self.input_timeout, args=())
        timeout_thread.daemon = True
        timeout_thread.start()

        Gtk.main()
        return self.accepted 
Example #26
Source File: wizard.py    From syncthing-gtk with GNU General Public License v2.0 5 votes vote down vote up
def init_page(self):
		""" Well, it's last page. """
		label = WrappedLabel(
			"<b>" + _("Done.") + "</b>" +
			"\n\n" +
			_("Syncthing has been successfully configured.") +
			"\n" +
			_("You can configure more details later, in "
			  "<b>UI Settings</b> and <b>Daemon Settings</b> menus "
			  "in main window of application.")
		)
		self.attach(label, 0, 0, 1, 1) 
Example #27
Source File: indicator.py    From lplayer with MIT License 5 votes vote down vote up
def main_window_is_hidden(self):
        self.show_main_window.set_label(_('Show main window')) 
Example #28
Source File: indicator.py    From lplayer with MIT License 5 votes vote down vote up
def on_show_main_window(self, widget):
        if self.main_window.is_visible():
            self.main_window.hide()
            self.show_main_window.set_label(_('Show main window'))
        else:
            self.main_window.show()
            self.show_main_window.set_label(_('Hide main window')) 
Example #29
Source File: wizard.py    From syncthing-gtk with GNU General Public License v2.0 5 votes vote down vote up
def prepare(self):
		# Configure main app to manage Syncthing daemon by default
		self.parent.config["autostart_daemon"] = 1
		self.parent.config["autokill_daemon"] = 1
		self.parent.config["minimize_on_start"] = False
		if IS_WINDOWS:
			self.parent.config["use_old_header"] = True
		self.parent.quit_button.get_parent().remove(self.parent.quit_button)
		self.parent.finished = True 
Example #30
Source File: wifi_window.py    From kano-settings with GNU General Public License v2.0 5 votes vote down vote up
def create_wifi_gui(is_plug, socket_id, no_confirm_ether=False):
    base_class = get_window_class(is_plug)
    wifi_gui = get_wifi_gui(base_class)

    iface = get_wlan_device()  # this is now redundant, moved to _launch_application
    win = wifi_gui(socket_id=socket_id, wiface=iface, no_confirm_ether=no_confirm_ether)
    win.show_all()
    Gtk.main()