當前位置: 首頁>>代碼示例>>Python>>正文


Python Application.run方法代碼示例

本文整理匯總了Python中dtk.ui.application.Application.run方法的典型用法代碼示例。如果您正苦於以下問題:Python Application.run方法的具體用法?Python Application.run怎麽用?Python Application.run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dtk.ui.application.Application的用法示例。


在下文中一共展示了Application.run方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: WorkListApp

# 需要導入模塊: from dtk.ui.application import Application [as 別名]
# 或者: from dtk.ui.application.Application import run [as 別名]
class WorkListApp(gobject.GObject):
	def __init__(self):
		gobject.GObject.__init__(self)
		
		self.app = Application(False)
		self.app.window.set_size_request(500, 300)
		# Add app titlebar.
		self.app.add_titlebar(["theme", "menu", "max", "min", "close"],
								None, "WorkList for Deepin", " ", 
								add_separator = True)        
		self.app.set_icon(app_theme.get_pixbuf('icon/worklist.png'))
		self.app.set_skin_preview(app_theme.get_pixbuf('frame.png'))

		self.win = self.app.window
		self.win.set_resizable(False)
		self.app.run()
開發者ID:hualet,項目名稱:deepin-ui-worklist,代碼行數:18,代碼來源:instance.py

示例2: Application

# 需要導入模塊: from dtk.ui.application import Application [as 別名]
# 或者: from dtk.ui.application.Application import run [as 別名]
    # Init application.
    application = Application()

    # Set application default size.
    application.set_default_size(DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT)

    # Set application icon.
    application.set_icon(os.path.join(get_current_dir(__file__), "icon.ico"))
    
    # Set application preview pixbuf.
    application.set_skin_preview(os.path.join(get_current_dir(__file__), "frame.png"))
    
    # Add titlebar.
    application.add_titlebar(
        ["theme", "max", "min", "close"], 
        os.path.join(get_current_dir(__file__), "logo.png"), 
        "Tab demo",
        "Tab demo",
        )
    
    tabbox = TabBox()
    align = gtk.Alignment()
    align.set(0.5, 0.5, 1, 1)
    align.set_padding(2, 2, 2, 2)
    align.add(tabbox)
    
    
    application.main_box.pack_start(align)

    application.run()
開發者ID:Jiarui315,項目名稱:deepin-ui,代碼行數:32,代碼來源:tab_demo.py

示例3: UpdateManager

# 需要導入模塊: from dtk.ui.application import Application [as 別名]
# 或者: from dtk.ui.application.Application import run [as 別名]

#.........這裏部分代碼省略.........

    def draw_mask(self, cr, x, y, w, h):
        sidebar_color = ui_theme.get_color("menu_select_font").get_color()
        draw_vlinear(cr, x, y, w, h,
                     [(0, (sidebar_color, 0.9)),
                      (1, (sidebar_color, 0.9)),]
                     )

    def start_dsc_backend(self):
        self.system_bus = dbus.SystemBus()
        bus_object = self.system_bus.get_object(DSC_SERVICE_NAME, DSC_SERVICE_PATH)
        self.bus_interface = dbus.Interface(bus_object, DSC_SERVICE_NAME)
        self.system_bus.add_signal_receiver(
                self.backend_signal_receiver, 
                signal_name="update_signal", 
                dbus_interface=DSC_SERVICE_NAME, 
                path=DSC_SERVICE_PATH)

    def backend_signal_receiver(self, messages):
        for message in messages:
            (signal_type, action_content) = message
            
            if signal_type == "update-list-update":
                self.in_update_list = True
                message_str = "正在檢查更新,請稍等...(%s%%)" % int(float(action_content[0]))
                self.update_info_label.set_text(message_str)
                self.upgrade_button.set_sensitive(False)
            elif signal_type == 'update-list-finish':
                message_str = "正在檢查更新,請稍等..."
                self.update_info_label.set_text(message_str)
                self.in_update_list = False

                self.bus_interface.request_upgrade_pkgs(
                        reply_handler=self.render_upgrade_info, 
                        error_handler=lambda e:handle_dbus_error("request_upgrade_pkgs", e))
            elif signal_type == 'update-list-failed':
                message_str = '檢查更新失敗!'
                self.update_info_label.set_text(message_str)

            elif signal_type == 'upgrade-commit-update':
                pkg_names, action_type, percent, status = action_content
                message_str = "[%s%%]%s" % (percent, status)
                self.update_info_label.set_text(message_str)
                self.upgrade_button.set_sensitive(False)
                self.in_upgrade_packages = True

            elif signal_type == 'upgrade-commit-finish':
                self.in_upgrade_packages = False
                message_str = '軟件更新完成!'
                self.update_info_label.set_text(message_str)

    def upgrade_packages(self, widget):
        if self.in_update_list:
            print 'Check update, please wait...'
        elif self.in_upgrade_packages:
            print 'Upgrade packages, please wait...'
        else:
            self.upgrade_button.set_sensitive(False)
            self.in_upgrade_packages = True
            all_upgrade_pkgs = []
            for info in self.upgrade_pkg_infos:
                all_upgrade_pkgs.append(str(eval(info)[0]))
            self.bus_interface.upgrade_pkgs_with_new_policy(
                    all_upgrade_pkgs,
                    reply_handler=lambda :handle_dbus_reply("upgrade_pkgs_with_new_policy"), 
                    error_handler=lambda e:handle_dbus_error("upgrade_pkgs_with_new_policy", e),
                    )

    def render_upgrade_info(self, pkg_infos):
        self.upgrade_pkg_infos = pkg_infos
        if len(pkg_infos) > 0:
            msg_str = '您的係統有%s個更新!' % (len(pkg_infos),)
            self.upgrade_button.set_sensitive(True)
        else:
            msg_str = '您的係統已經最新狀態了~'
            self.upgrade_button.set_sensitive(False)

        self.update_info_label.set_text(msg_str)
        self.application.window.show_all()

    def run(self):
        self.start_dsc_backend()
        container_remove_all(self.background)
        self.background.pack_start(self.update_info_label_align)

        gtk.timeout_add(1000, lambda:self.bus_interface.start_update_list(
                reply_handler=lambda :handle_dbus_reply("start_update_list"),
                error_handler=lambda e:handle_dbus_error("start_update_list", e)))

        self.application.run()
        self.bus_interface.request_quit(
                reply_handler=lambda :handle_dbus_reply("request_quit"), 
                error_handler=lambda e:handle_dbus_error("request_quit", e))

    def quit(self):
        gtk.main_quit()

    @dbus.service.method(DSC_UPDATE_MANAGER_NAME, in_signature="", out_signature="")    
    def hello(self):
        self.application.window.present()
開發者ID:iceleaf916,項目名稱:software-update-manager,代碼行數:104,代碼來源:main.py


注:本文中的dtk.ui.application.Application.run方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。