python类Label()的实例源码

emoji_picker.py 文件源码 项目:ibus-typing-booster 作者: mike-fabian 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def _emoji_label_set_tooltip( # pylint: disable=no-self-use
            self, emoji, label):
        '''
        Set the tooltip for a label in the flowbox which shows an emoji

        :param emoji: The emoji
        :type emoji: String
        :param label: The label used to show the emoji
        :type label: Gtk.Label object
        '''
        tooltip_text = _('Left click to copy') + '\n'
        if len(self._emoji_matcher.skin_tone_variants(emoji)) > 1:
            tooltip_text += (
                _('Long press or middle click for skin tones')  + '\n')
        tooltip_text += _('Right click for info')
        label.set_tooltip_text(tooltip_text)
msgbox.py 文件源码 项目:SolStudio 作者: alianse777 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def confirm(parent=None, title="", text=""):
    dialog = Gtk.Dialog(title, parent, 0)

    dialog.set_default_size(150, 100)
    dialog.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("white"))
    label = Gtk.Label()
    label.set_markup('<span foreground="#494941" face="sans">' + text + '</span>')
    box = dialog.get_content_area()
    box.add(label)
    box.show_all()
    btn1 = dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
    btn1.set_relief(2)
    btn2 = dialog.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK)
    btn2.set_relief(2)
    result = False
    response = dialog.run()
    dialog.destroy()
    if response == Gtk.ResponseType.OK:
        result = True
    elif response == Gtk.ResponseType.CANCEL:
        result = False
    return result
partinfo.py 文件源码 项目:apart-gtk 作者: alexheretic 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, part: Dict[str, Any], core: ApartCore, main_view: 'MainView'):
        Gtk.Box.__init__(self)
        self.part = part
        self.core = core
        self.main_view = main_view

        self.add(key_and_val('Name', self.name()))
        self.add(key_and_val('Type', self.part.get('fstype', 'unknown')))
        self.add(key_and_val('Label', self.part.get('label', 'none')))
        self.add(key_and_val('Size', humanize.naturalsize(self.part['size'], binary=True)))
        self.clone_button = Gtk.Button("Clone", halign=Gtk.Align.END)
        self.restore_button = Gtk.Button("Restore", halign=Gtk.Align.END)
        if self.is_mounted():
            self.clone_button.set_sensitive(False)
            self.clone_button.set_tooltip_text('Partition is currently mounted')
            self.restore_button.set_sensitive(False)
            self.restore_button.set_tooltip_text('Partition is currently mounted')
        else:
            self.clone_button.connect('clicked', lambda b: self.main_view.show_new_clone())
            self.restore_button.connect('clicked', lambda b: self.main_view.show_new_restore())
        buttons = Gtk.Box(hexpand=True, halign=Gtk.Align.END)
        buttons.add(self.clone_button)
        buttons.add(self.restore_button)
        self.add(buttons)
        main_view.connect('notify::visible-child', self.on_main_view_change)
dialog.py 文件源码 项目:apart-gtk 作者: alexheretic 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, root: Gtk.Window, text: str,
                 ok_button_text: str = Gtk.STOCK_OK,
                 cancel_button_text: str = Gtk.STOCK_CANCEL,
                 header: str = '',
                 message_type: Gtk.MessageType = Gtk.MessageType.WARNING):
        Gtk.MessageDialog.__init__(self, root, 0, message_type=message_type)
        self.set_title(header)
        self.icon = Gtk.Image()
        self.icon.set_from_icon_name(appropriate_icon(message_type), Gtk.IconSize.LARGE_TOOLBAR)
        self.text = Gtk.Label(text)
        heading = Gtk.Box()
        heading.add(self.icon)
        heading.add(self.text)

        self.get_message_area().add(heading)
        self.get_message_area().set_spacing(0)
        self.add_button(cancel_button_text, Gtk.ResponseType.CANCEL)
        self.add_button(ok_button_text, Gtk.ResponseType.OK)
        self.show_all()
dialog.py 文件源码 项目:apart-gtk 作者: alexheretic 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, root: Gtk.Window, text: str,
                 ok_button_text: str = Gtk.STOCK_OK,
                 header: str = '',
                 message_type: Gtk.MessageType = Gtk.MessageType.ERROR):
        Gtk.MessageDialog.__init__(self, root, 0, message_type=message_type)
        self.set_title(header)
        self.icon = Gtk.Image()
        self.icon.set_from_icon_name(appropriate_icon(message_type), Gtk.IconSize.LARGE_TOOLBAR)
        self.text = Gtk.Label(text)
        heading = Gtk.Box()
        heading.add(self.icon)
        heading.add(self.text)

        self.get_message_area().add(heading)
        self.get_message_area().set_spacing(0)
        self.add_button(ok_button_text, Gtk.ResponseType.OK)
        self.show_all()
dynamic_sizing.py 文件源码 项目:ghetto_omr 作者: pohzhiee 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self):
        Gtk.Window.__init__(self,title="Ghetto OMR")
        self.set_resizable(True)
        self.connect("configure-event",self.new_dim)
        self.connect("delete-event",Gtk.main_quit)

        self.win_width = 200
        self.win_height = 200

        something = Gtk.Label("SOMETHING")
        self.maximize()
        self.count =0


        self.main = MainGrid(self)
        self.add(self.main)
        #
        # self.main.destroy()
        # self.main = Gtk.Label("SOMETHING")
        # self.add(self.main)
ControlsGTK.py 文件源码 项目:pycam 作者: SebKuzminsky 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def update_widgets(self):
        widgets = list(self._widgets)
        widgets.sort(key=lambda item: item.weight)
        # remove all widgets from the table
        for child in self._table.get_children():
            self._table.remove(child)
        # add the current controls
        for index, widget in enumerate(widgets):
            if hasattr(widget.widget, "get_label"):
                # checkbox
                widget.widget.set_label(widget.label)
                self._table.attach(widget.widget, 0, 2, index, index + 1, xoptions=gtk.Align.FILL,
                                   yoptions=gtk.Align.FILL)
            elif not widget.label:
                self._table.attach(widget.widget, 0, 2, index, index + 1, xoptions=gtk.Align.FILL,
                                   yoptions=gtk.Align.FILL)
            else:
                # spinbutton, combobox, ...
                label = gtk.Label("%s:" % widget.label)
                label.set_alignment(0.0, 0.5)
                self._table.attach(label, 0, 1, index, index + 1, xoptions=gtk.Align.FILL,
                                   yoptions=gtk.Align.FILL)
                self._table.attach(widget.widget, 1, 2, index, index + 1, xoptions=gtk.Align.FILL,
                                   yoptions=gtk.Align.FILL)
        self._update_widgets_visibility()
viewergrid.py 文件源码 项目:PyFlowChart 作者: steelcowboy 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def add_year(self, year_number):
        # Create a new grid for the year 
        year_grid = yearGrid(year_number)
        # Update map of years
        self.year_map[year_number] = year_grid
        label_box = Gtk.EventBox()
        label_box.connect('button-press-event', self.year_clicked)
        label = Gtk.Label(self.nth[year_number] + " Year")
        label_box.add(label)

        left_separator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL)
        left_separator.set_margin_start(1)
        left_separator.set_margin_end(10)
        self.attach(left_separator, self.new_column(), 0, 1, 3)

        self.attach(year_grid, self.new_column(), 2, 1, 1)
        self.attach(label_box, self.width, 0, 1, 1)

        right_separator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL)
        right_separator.set_margin_start(10)
        right_separator.set_margin_end(1)
        self.attach(right_separator, self.new_column(), 0, 1, 3)
editable_label.py 文件源码 项目:PyFlowChart 作者: steelcowboy 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, text=None):
        Gtk.EventBox.__init__(self)
        self.text = text 
        self.has_entry = False 

        if text is not None:
            self.label = Gtk.Label(text)
            self.add(self.label)
        else:
            self.entry = Gtk.Entry()
            self.entry.connect('activate', self.enter_key)
            self.add(self.entry)
            self.has_entry = True 

        self.connect('button-press-event', self.double_click)


        self.show_all()
history_item_view.py 文件源码 项目:draobpilc 作者: awamper 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self):
        super().__init__()

        self.set_name('HistoryItemViewShortcutHint')
        self.set_no_show_all(True)
        self.set_vexpand(False)
        self.set_hexpand(False)
        self.set_valign(Gtk.Align.START)
        self.set_halign(Gtk.Align.START)
        self.set_size_request(40, 40)

        self.label = Gtk.Label()
        self.label.set_halign(Gtk.Align.CENTER)
        self.label.set_valign(Gtk.Align.CENTER)
        self.label.set_vexpand(False)
        self.label.set_hexpand(True)
        self.label.show()

        self.add(self.label)
easybuttons.py 文件源码 项目:ukui-menu 作者: ukui 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def addLabel( self, text, styles = None ):
        label = Gtk.Label()
        label.set_name("startup-label")
        if "<b>" in text or "<span" in text:
            label.set_markup(text.replace('&', '&amp;')) # don't remove our pango
        else:
            label.set_text(text)

        if styles:
            labelStyle = Pango.AttrList()
            for attr in styles:
                labelStyle.insert( attr )
            label.set_attributes( labelStyle )

        label.set_ellipsize( Pango.EllipsizeMode.END )
        label.set_alignment( 0.0, 0.5 )
        label.show()
        self.labelBox.pack_start( label , True, True, 0)
keybinding.py 文件源码 项目:ukui-menu 作者: ukui 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, desc):
        super(KeybindingWidget, self).__init__()
        self.desc = desc
        self.label = Gtk.Label(desc)
        if self.desc != "":
            self.pack_start(self.label, False, False, 0)
        self.button = Gtk.Button()
        self.button.set_tooltip_text(_("Click to set a new accelerator key for opening and closing the menu.  ") +
                                     _("Press Escape or click again to cancel the operation.  ") +
                                     _("Press Backspace to clear the existing keybinding."))
        self.button.connect("clicked", self.clicked)
        self.button.set_size_request(200, -1)
        self.pack_start(self.button, False, False, 4)

        self.show_all()
        self.event_id = None
        self.teaching = False
VulnerabilitiesSpider.py 文件源码 项目:Vulnerabilities-spider 作者: muhammad-bouabid 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, parent):
      Gtk.Dialog.__init__(self, "Something", parent,
          Gtk.DialogFlags.MODAL, buttons=(
          Gtk.STOCK_NEW, Gtk.ResponseType.OK,
          Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))

      self.set_default_size(400, 600)

      box = self.get_content_area()

      label = Gtk.Label("Insert text you want to search for:")
      box.add(label)

#        self.entry = Gtk.Entry()
#        box.add(self.entry)

      self.main_area = Gtk.Stack()
      self.main_area.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT)

      self.main_area.set_transition_duration(1000)

      self.entry = Gtk.Entry()
      self.main_area.add_titled(self.entry, "entry_name", "Entry Url")

      self.labelS = Gtk.Label()
      self.label_txt = """<big><i>you have choice to runn the scan directly or after setup the scanning process you want to follow on your target</i></big>"""
      self.labelS.set_markup(self.label_txt)
      self.labelS.set_line_wrap(True)
      self.main_area.add_titled(self.labelS, "label_name", "How Scan will Start")

      self.our_stackSwitcher = Gtk.StackSwitcher()
      self.our_stackSwitcher.set_stack(self.main_area)

      box.add(self.our_stackSwitcher)
      box.add(self.main_area)

      self.show_all()


#~~~~~~~~~~~~ History Dialog ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
__main__.py 文件源码 项目:duck-feed 作者: h0m3stuck 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def create_feed_entry(title, url, description):
    container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
    title_label = Gtk.Label(title)
    link_button = Gtk.LinkButton(url, url)
    description_view = WebKit2.WebView()
    description_view.set_size_request(400, 400)
    description_view.load_html(description)
    container.add(title_label)
    container.add(link_button)
    container.add(description_view)
    container.show()
    title_label.show()
    link_button.show()
    description_view.show()
    return container
__main__.py 文件源码 项目:duck-feed 作者: h0m3stuck 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def add_new_feed_tab(self, title, entries):
        scrolled_window = Gtk.ScrolledWindow()
        container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        label = Gtk.Label(title)
        for entry in entries:
            box = create_feed_entry(entry.title, entry.link, entry.description)
            box.show()
            container.add(box)
        label.show()
        scrolled_window.add(container)
        scrolled_window.set_vexpand(True)
        scrolled_window.set_overlay_scrolling(False) # show manly scrollbars
        self.notebook.append_page(scrolled_window, label)
        scrolled_window.show_all()
gtkui.py 文件源码 项目:yt-browser 作者: juanfgs 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def on_video_search1_activated(self,searchbox):
        """ Start searching when the user presses enter """

        # Show a spinner to the user while the results are being retrieved
        spinner = Gtk.Spinner()
        searching = Gtk.Label("Buscando...")

        # iterate through the list items and remove child items
        self.video_list.foreach(lambda child: self.video_list.remove(child))

        # Show the spinner and searching label
        self.video_list.add(spinner)
        self.video_list.add(searching)
        spinner.start()

        # Update the changes
        self.video_list.show_all()

        #we spawn a new thread to consume the api asynchronously
        def start_search():
            #for now we use a single backend

            self.search_response = self.backend.search(searchbox.get_text())
            for search_result in self.search_response.get("items",[]):
                if search_result["id"]["kind"] == "youtube#video":
                    GLib.idle_add(spinner.destroy)
                    GLib.idle_add(searching.destroy)
                    GLib.idle_add(self.update_list,search_result)
                    GLib.idle_add(self.video_list.show)


        self.download_thread = threading.Thread(target=start_search)
        self.download_thread.daemon = True
        self.download_thread.start()
games_nebula.py 文件源码 项目:games_nebula 作者: yancharkin 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def create_loading_window(self):

        self.loading_window = Gtk.Window(
            title = "Games Nebula",
            icon = app_icon,
            type = Gtk.WindowType.POPUP,
            window_position = Gtk.WindowPosition.CENTER_ALWAYS,
            resizable = False
            )

        self.box_loading_window = Gtk.Box()

        loading_icon = app_icon.scale_simple(32, 32, InterpType.BILINEAR)

        self.image_loading = Gtk.Image(
            pixbuf = loading_icon,
            margin_left = 10,
            margin_right = 10
            )

        self.label_loading = Gtk.Label(
            label = _("Launching 'Games Nebula'"),
            margin_right = 10,
            margin_left = 10,
            margin_top = 20,
            margin_bottom = 20
            )

        self.box_loading_window.pack_start(self.image_loading, True, True, 0)
        self.box_loading_window.pack_start(self.label_loading, True, True, 0)
        self.loading_window.add(self.box_loading_window)
        self.loading_window.show_all()
ui.py 文件源码 项目:fpi 作者: solus-cold-storage 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def build_contents(self):
        """ Build the main UI display regions """
        self.stack = Gtk.Stack()
        self.box.pack_start(self.stack, True, True, 0)

        button = Gtk.Button("Install")
        lab_disclaimer = Gtk.Label(
            "This is a third party package and is not officially supported"
            " by Solus")
        img_warn = Gtk.Image.new_from_icon_name(
            "dialog-warning-symbolic", Gtk.IconSize.BUTTON)
        self.abar.pack_start(img_warn)
        self.abar.pack_start(lab_disclaimer)
        self.abar.pack_end(button)
        button.get_style_context().add_class("destructive-action")

        # Details
        dumb = Gtk.Label("Details ...")
        self._fix_label(dumb)
        dumb.set_property("margin", 12)
        self.stack.add_titled(dumb, "desc", "Details")

        # Files
        dumb = Gtk.Label("Files ...")
        self._fix_label(dumb)
        dumb.set_property("margin", 12)
        self.stack.add_titled(dumb, "files", "Files")
mooncalendarwindow.py 文件源码 项目:my-weather-indicator 作者: atareao 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, adate=None):
        Gtk.EventBox.__init__(self)
        self.set_size_request(100, 70)
        box1 = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
        self.add(box1)
        self.label = Gtk.Label()
        box1.pack_start(self.label, True, True, padding=1)
        self.image = Gtk.Image()
        box1.pack_start(self.image, True, True, padding=1)
        if adate is not None:
            self.set_date(adate)
        self.image.show()
forecastw.py 文件源码 项目:my-weather-indicator 作者: atareao 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def get_image_with_text2(text, image=None):
    vbox = Gtk.VBox()
    if image:
        # image = Gtk.Image.new_from_file(os.path.join(comun.IMAGESDIR,image))
        image = load_image(os.path.join(comun.IMAGESDIR, image))
        image.set_alignment(0.5, 0.5)
        vbox.pack_start(image, True, True, 0)
    label = Gtk.Label.new(text)
    label.set_alignment(0.5, 0.5)
    vbox.pack_start(label, True, True, 0)
    return vbox


问题


面经


文章

微信
公众号

扫码关注公众号