当前位置: 首页>>代码示例>>Python>>正文


Python Application.set_menu_callback方法代码示例

本文整理汇总了Python中dtk.ui.application.Application.set_menu_callback方法的典型用法代码示例。如果您正苦于以下问题:Python Application.set_menu_callback方法的具体用法?Python Application.set_menu_callback怎么用?Python Application.set_menu_callback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dtk.ui.application.Application的用法示例。


在下文中一共展示了Application.set_menu_callback方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: map

# 需要导入模块: from dtk.ui.application import Application [as 别名]
# 或者: from dtk.ui.application.Application import set_menu_callback [as 别名]
      (None,
       "测试测试测试", None),
      (None,
       "测试测试测试", None),
      (None,
       "测试测试测试4", None, (1, 2, 3)),
      (None,
       "测试测试测试5", None),
      (None,
       "测试测试测试6", None),
      ],
     True
     )
 menu.set_menu_item_sensitive_by_index(1, False)
 application.set_menu_callback(lambda button: menu.show(
         get_widget_root_coordinate(button, WIDGET_POS_BOTTOM_LEFT),
         (button.get_allocation().width, 0)))
 
 # Add navigatebar.
 tab_window_items = map(create_tab_window_item, ["Tab1", "Tab2", "Tab3", "Tab4", "Tab5"])
 
 droplist = Droplist(
     [("测试测试测试1", None),
      ("测试测试测试2", None),
      ("测试测试测试3", None),
      None,
      ("测试测试测试", None),
      None,
      ("测试测试测试4", None),
      ("测试测试测试5", None),
      ("测试测试测试6", None),
开发者ID:liuhuan520,项目名称:deepin-ui,代码行数:33,代码来源:demo.py

示例2: GUI

# 需要导入模块: from dtk.ui.application import Application [as 别名]
# 或者: from dtk.ui.application.Application import set_menu_callback [as 别名]
class GUI(object):
    """Media Player GUI kernel code.核心界面代码"""

    def __init__(self):
        """application."""
        self.__init_values()
        self.app = Application(False)
        # application set.
        app_w, app_h = 800, 570  # 初始化宽,高.
        min_app_w, min_app_h = 480, 300  # 防止超过,界面布局被破坏.
        self.app.set_default_size(min_app_w, min_app_h)
        self.app.window.set_default_size(app_w, app_h)
        # self.app.window.resize
        image_dir = os.path.join(get_parent_dir(__file__, 2), "image")
        self.app.set_icon(os.path.join(image_dir, "icon.ico"))
        self.app.set_skin_preview(os.path.join(os.path.join(image_dir, "frame.png")))
        # set titlebar.
        self.app.add_titlebar(["theme", "menu", "max", "min", "close"],
                              os.path.join(os.path.join(image_dir, "logo.png")),
                              _("DPlayer"), " ",
                              add_separator=False)
        #
        self.play_menus = PlayMenus()
        # 设置主题菜单.
        self.app.set_menu_callback(lambda button: self.play_menus.show_theme_menu(button))
        #
        self.main_ali = gtk.Alignment()
        self.main_vbox = gtk.VBox()
        self.main_ali.add(self.main_vbox)
        self.main_ali.set(0, 0, 1.0, 1.0)
        self.main_ali.set_padding(0, 2, 2, 2)
        #
        self.mid_combo_event = gtk.EventBox()
        self.mid_combo_event.connect("expose-event", self.mid_combo_event_expose_event)
        self.screen_mid_combo = ScreenMidCombo()
        self.mid_combo_event.set_visible_window(True)
        self.mid_combo_event.add(self.screen_mid_combo)
        # movie screen. 电影播放屏幕.
        # 播放屏幕和播放列表的HBOX.
        self.play_list_view = PlayListView()
        self.screen_paned = Paned()
        self.screen_paned.paint_bottom_window = self.__paint_bottom_toolbar_background
        self.screen_frame = gtk.Alignment(0.0, 0.0, 1.0, 1.0)
        self.screen = gtk.DrawingArea()
        self.screen_frame.add(self.screen)
        self.top_toolbar = ToolBar()
        self.bottom_toolbar = BottomToolBar()
        # BUG: 当显示上部工具条的时候,画面抖动.
        self.screen_paned.add_top_widget(self.top_toolbar.hbox_hframe)
        self.screen_paned.add_bottom_widget(self.bottom_toolbar.vbox)
        #self.screen_paned.add_mid_widget(self.screen_mid_combo)
        self.screen_paned.add_mid_widget(self.mid_combo_event)
        #
        self.screen_frame_event = self.screen_paned
        self.screen_paned.screen = self.screen
        #
        self.screen_paned.add1(self.screen_frame)
        self.screen_paned.add2(self.play_list_view.play_list_vbox)
        #
        self.play_control_panel = BottomToolBar(False)
        #
        self.main_vbox.pack_start(self.screen_paned, True, True)
        self.main_vbox.pack_start(self.play_control_panel.vbox, False, False)
        #
        self.app.main_box.pack_start(self.main_ali, True, True)

    def __init_values(self):
        self.child2_show_check = False  # True 显示 False 隐藏

    ################################################################################
    ##
    def __paint_bottom_toolbar_background(self, e):
        # 将皮肤的图片画在bottom toolbar上,作为背景.
        cr = e.window.cairo_create()
        bottom_size = e.window.get_size()
        # draw background.
        cr.set_source_rgba(*alpha_color_hex_to_cairo(("#ebebeb", 0.1)))
        cr.rectangle(0, 0, bottom_size[0], bottom_size[1])
        cr.fill()
        # draw background pixbuf.
        pixbuf = skin_config.background_pixbuf
        app_h = self.app.window.allocation.height
        app_w = self.app.window.allocation.width
        bottom_h = bottom_size[1]
        # 当图片的高度小雨窗口高度的时候,只拿出图片的最尾巴.
        if pixbuf.get_height() > app_h + bottom_h:
            h = app_h
        else:
            h = pixbuf.get_height() - bottom_h
            # 当图片小于窗口宽度的时候,拉伸图片.
        if pixbuf.get_width() < app_w:
            pixbuf = pixbuf.scale_simple(app_w,
                                         pixbuf.get_width(),
                                         gtk.gdk.INTERP_BILINEAR)

        draw_pixbuf(cr,
                    pixbuf,
                    0,
                    -h)

#.........这里部分代码省略.........
开发者ID:nohappiness,项目名称:deepin-media-player,代码行数:103,代码来源:gui.py

示例3: GameCenterApp

# 需要导入模块: from dtk.ui.application import Application [as 别名]
# 或者: from dtk.ui.application.Application import set_menu_callback [as 别名]

#.........这里部分代码省略.........
                padding_y = 16,
                vertical=False,
                item_normal_pixbuf=DynamicPixbuf(get_common_image('top/nav_normal.png')),
                item_hover_pixbuf=DynamicPixbuf(get_common_image('top/nav_hover.png')),
                item_press_pixbuf=DynamicPixbuf(get_common_image('top/nav_press.png')),
                )
        self.navigatebar.set_size_request(-1, 56)
        self.navigatebar_align = gtk.Alignment(0, 0, 1, 1)
        self.navigatebar_align.set_padding(0, 0, 4, 0)
        self.navigatebar_align.add(self.navigatebar)
        self.application.titlebar.set_size_request(-1, 56)
        self.application.titlebar.left_box.pack_start(self.navigatebar_align, True, True)
        self.application.window.add_move_event(self.navigatebar)

        self.about_dialog = AboutDialog(_('About us'))
        self.about_dialog.set_transient_for(self.application.window)

        # Init menu.
        #if LANGUAGE == 'en_US':
            #menu_min_width = 185
        #else:
            #menu_min_width = 150

        menu = Menu(
            [
             (None, _("Clear all cached data"), self.clean_download_cache),
             (None, _("See what's new"), lambda : self.show_wizard_win()),
             (None, _("About us"), self.show_about_dialog),
             (None, _("Quit"), lambda: gtk.main_quit()),
             ],
            is_root_menu=True,
            #menu_min_width=menu_min_width,
            )
        self.application.set_menu_callback(
            lambda button:
                menu.show(
                get_widget_root_coordinate(button, WIDGET_POS_BOTTOM_LEFT),
                (button.get_allocation().width, 0)))
        
        self.no_favorite_html_path = os.path.join(static_dir, "error-no-favorite.html")
        self.no_recent_html_path = os.path.join(static_dir, "error-no-recent.html")
        self.mygame_frame_path = os.path.join(static_dir, "mygame-frame.html")
        self.gallery_html_path = os.path.join(static_dir, 'game-mygame.html')

        skin_config.connect('theme-changed', self.theme_changed_handler)
        global_event.register_event('show-message', self.update_message)

    def page_box_render(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.get_allocation()
        cr.set_source_rgb(1, 1, 1)
        cr.rectangle(*rect)
        cr.fill()

    def check_network_connection(self):
        if is_network_connected():
            self.network_connected_flag = True
            self.webview.load_uri(self.home_url)
            self.switch_page_view(self.webview)
        else:    
            self.network_connected_flag = False
            self.switch_page_view(self.network_failed_box)
    
    def switch_page_view(self, box):
        container_remove_all(self.page_box)
        self.page_box.add(box)
开发者ID:huowa222,项目名称:deepin-game-center,代码行数:70,代码来源:game_center.py

示例4: DeepinSoftwareCenter

# 需要导入模块: from dtk.ui.application import Application [as 别名]
# 或者: from dtk.ui.application.Application import set_menu_callback [as 别名]

#.........这里部分代码省略.........
                ],
                font_size = 11,
                padding_x = 2,
                padding_y = 2,
                vertical=False,
                item_hover_pixbuf=DynamicPixbuf(utils.get_common_image("navigatebar/nav_hover.png")),
                item_press_pixbuf=DynamicPixbuf(utils.get_common_image("navigatebar/nav_press.png")),
                )
        self.navigatebar.set_size_request(-1, 56)
        self.navigatebar_align = gtk.Alignment(0, 0, 1, 1)
        self.navigatebar_align.set_padding(0, 0, 4, 0)
        self.navigatebar_align.add(self.navigatebar)
        self.application.titlebar.set_size_request(-1, 56)
        self.application.titlebar.left_box.pack_start(self.navigatebar_align, True, True)
        self.application.window.add_move_event(self.navigatebar)

        # Init menu.
        if LANGUAGE == 'en_US':
            menu_min_width = 185
        else:
            menu_min_width = 150
        menu = Menu(
            [
             (None, _("Refresh package lists"), lambda:global_event.emit('start-update-list')),
             (None, _("Open download directory"), self.open_download_directory),
             (None, _("Clear up cached packages"), self.clean_download_cache),
             (None, _("View new features"), lambda : self.show_wizard_win()),
             (self.get_pixbuf_group("menu", "setting"), _("Preferences"), self.show_preference_dialog),
             (self.get_pixbuf_group("menu", "close"), _("Quit"), self.exit),
             ],
            is_root_menu=True,
            menu_min_width=menu_min_width,
            )
        self.application.set_menu_callback(
            lambda button:
                menu.show(
                get_widget_root_coordinate(button, WIDGET_POS_BOTTOM_LEFT),
                (button.get_allocation().width, 0)))

        self.preference_dialog = DscPreferenceDialog()

        if hasattr(self, 'recommend_status'):
            self.init_home_page(self.recommend_status)
        else:
            self.init_home_page()

    def get_pixbuf_group(self, folder, name):
        return (app_theme.get_pixbuf("%s/%s_normal.png" % (folder, name)),
                app_theme.get_pixbuf("%s/%s_hover.png" % (folder, name)),
                app_theme.get_pixbuf("%s/%s_disable.png" % (folder, name)),
                )

    def application_close_window(self, widget=None, event=None):
        self.application.window.hide_all()
        gtk.main_quit()

        return True

    def upgrade_finish_action(self, pkg_info_list):
        return
        """
        if len(pkg_info_list) > 0:
            # Delete items from treeview.
            upgraded_items = []

            for (pkg_name, marked_delete, marked_install, marked_upgrade) in pkg_info_list:
开发者ID:kissthink,项目名称:deepin-store,代码行数:70,代码来源:software_center.py


注:本文中的dtk.ui.application.Application.set_menu_callback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。