本文整理汇总了Python中window.Window.hide方法的典型用法代码示例。如果您正苦于以下问题:Python Window.hide方法的具体用法?Python Window.hide怎么用?Python Window.hide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类window.Window
的用法示例。
在下文中一共展示了Window.hide方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Application
# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import hide [as 别名]
class Application(Gtk.Application):
simplename = "video-games"
fullname = "Video Games"
application_id = 'org.gnome.' + simplename
def __init__(self):
print (time.time()-start_time, "start init application")
Gtk.Application.__init__(self, application_id = self.application_id, flags = Gio.ApplicationFlags.FLAGS_NONE)
GLib.threads_init()
Gdk.threads_init()
self.datadir = os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0])))
self.savedatadir = Environement.save_data_path()
self.systems = Badnik.SystemCollection.full ()
self.gamesdb = Badnik.Library(db_name = "games", db_dir = self.savedatadir, systems = self.systems)
#self.gamesdb.app = self
self.gamesdb.path = os.path.join(self.savedatadir, "games.db")
self.focused_game = None
self.connect("activate", self.on_activate)
self.register(None)
self.settings = Gio.Settings.new(self.application_id)
self.builder = Gtk.Builder()
self.builder.add_from_file(Environement.get_resource("AppMenu.ui"))
self.builder.connect_signals(self)
self.menumodel = self.builder.get_object("AppMenu")
self.set_app_menu(self.menumodel)
self._action_entries = [ { 'name': 'quit', 'callback': self.on_quit, 'accel': '<Primary>q' },
{ 'name': 'about', 'callback': self.on_about },
{ 'name': 'help', 'callback': self.on_help, 'accel': 'F1' },
#{ 'name': 'fullscreen', 'callback': self.on_fullscreen, 'accel': 'F11' },
#{ 'name': 'view-as', 'callback': self.on_view_as, 'create_hook': self._view_as_create_hook,
# 'parameter_type': 's', 'state': self.settings.get_value('view-as') },
{ 'name': 'add-games', 'callback': self.on_add_games },
#{ 'name': 'download-metadata', 'callback': self.on_download_metadata, 'accel': '<Primary>m' }
]
self._add_actions()
settings = Gtk.Settings.get_default()
settings.set_property("gtk-application-prefer-dark-theme", True)
settings.set_property("gtk-shell-shows-app-menu", True)
print (time.time()-start_time, "end init application")
self.running_games = {}
self.systems.connect("game_found", self.on_game_found)
self.gamesdb.connect("game_added", self.on_game_added)
def on_activate(self, data=None):
#print (time.time()-start_time, "start activating application")
#print("start window")
self.window = Window(self)
self.window.show ()
self.window.connect('play_clicked', self.on_play_clicked)
#print("stop window")
self.window.connect("destroy", self.on_quit, None)
self.window.show()
self.add_window(self.window)
self.update_library_async()
#print (time.time()-start_time, "end activating application")
def on_play_clicked(self, window, game):
self.play(game)
def _add_actions(self):
for action_entry in self._action_entries:
state = action_entry['state'] if 'state' in action_entry else None
parameterType = GLib.VariantType.new(action_entry['parameter_type']) if 'parameter_type' in action_entry else None
action = None
if (state):
action = Gio.SimpleAction.new_stateful(action_entry['name'], parameterType, action_entry['state'])
else:
action = Gio.SimpleAction.new(action_entry['name'], None)
if 'create_hook' in action_entry:
action_entry['create_hook'](action)
if 'callback' in action_entry:
action.connect('activate', action_entry['callback'])
if 'accel' in action_entry:
self.add_accelerator(action_entry['accel'], 'app.' + action_entry['name'], None)
self.add_action(action)
def on_quit(self, action, data):
print("Quitting Badnik")
self.window.hide()
self.systems.set_property("stop_searches", True)
#.........这里部分代码省略.........
示例2: App
# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import hide [as 别名]
class App(KApplication):
def __init__(self):
KApplication.__init__(self)
self.setQuitOnLastWindowClosed(False)
self.sni = KStatusNotifierItem()
self.sni.setTitle(i18n("Deveba"))
self.sni.setCategory(KStatusNotifierItem.SystemServices)
self.sni.setStatus(KStatusNotifierItem.Active)
self.sni.setIconByName("task-accepted")
self.sni.setToolTipTitle(i18n("Deveba"))
self.window = Window(self)
self.window.hide()
self.window.finished.connect(self.slotWindowClosed)
self.sni.setAssociatedWidget(self.window)
self.logMessages = []
self.success = True
self.workerThread = None
@staticmethod
def options():
options = KCmdLineOptions()
options.add("log <file>", ki18n("Write log to file"), "-")
options.add("c").add("config <file>", ki18n("Config file to use"), core.CONFIG_FILE)
options.add("+[group]", ki18n("Start backup of $group"))
return options
def exec_(self):
args = KCmdLineArgs.parsedArgs()
core.setup_logger(str(args.getOption("log")))
config_file = args.getOption("config")
config = core.load_config(config_file)
if args.count() > 0:
group_names = [str(args.arg(x)) for x in range(args.count())]
groups = core.get_group_list(config, group_names)
self.startSync(groups)
else:
self.window.show()
return KApplication.exec_()
def startSync(self, groups):
self.success = True
self.workerThread = WorkerThread(groups)
self.workerThread.logCalled.connect(self.addLog, Qt.QueuedConnection)
self.sni.setIconByName("task-ongoing")
self.workerThread.start()
self.workerThread.finished.connect(self.slotSyncFinished)
def slotSyncFinished(self):
if self.success:
self.sni.setIconByName("task-accepted")
self.workerThread = None
QTimer.singleShot(2 * 60 * 1000, self.quitIfNoWindow)
def slotWindowClosed(self):
if self.workerThread is None:
self.quit()
def quitIfNoWindow(self):
if not self.window.isVisible():
self.quit()
def addLog(self, level, msg):
if level < UserInterface.LOG_INFO:
return
timestamp = time.localtime()
message = LogMessage(timestamp, level, msg)
self.logMessages.append(message)
texts = [x.formatted() for x in self.logMessages[-MAX_TEXTS_LENGTH:]]
html = "<ul>" + "".join(["<li>%s</li>" % x for x in texts]) + "</ul>"
self.sni.setToolTipSubTitle(html)
if level >= UserInterface.LOG_WARNING:
self.success = False
self.sni.setIconByName("dialog-error")
self.window.addLog(message)