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


Python Gtk.STOCK_OK属性代码示例

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


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

示例1: _config_chooser_dialog

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OK [as 别名]
def _config_chooser_dialog(self, title_text, description):
        """Dialog to select which config shall be exported

        :param title_text: Title text
        :param description: Description
        """
        dialog = Gtk.Dialog(title_text, self.view["preferences_window"],
                            flags=0, buttons=
                            (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
                             Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
        label = Gtk.Label(label=description)
        label.set_padding(xpad=10, ypad=10)
        dialog.vbox.pack_start(label, True, True, 0)
        label.show()
        self._gui_checkbox = Gtk.CheckButton(label="GUI Config")
        dialog.vbox.pack_start(self._gui_checkbox, True, True, 0)
        self._gui_checkbox.show()
        self._core_checkbox = Gtk.CheckButton(label="Core Config")
        self._core_checkbox.show()
        dialog.vbox.pack_start(self._core_checkbox, True, True, 0)
        response = dialog.run()
        dialog.destroy()
        return response 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:25,代码来源:preferences_window.py

示例2: addNewBank

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OK [as 别名]
def addNewBank(self, model):
        dialog = Gtk.Dialog(None, None,
                            Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
                            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                             Gtk.STOCK_OK, Gtk.ResponseType.OK))
        label = Gtk.Label(label='Bank Name:')
        entry = Gtk.Entry()
        dialog.vbox.pack_start(label, False, False, 0)
        dialog.vbox.pack_start(entry, False, False, 0)
        dialog.show_all()
        result = dialog.run()
        bank_name = entry.get_text()
        if result == Gtk.ResponseType.OK and len(bank_name) != 0:
            iter = model.append()
            model.set(iter, 0, bank_name)
            self.add_bank(bank_name)

        dialog.destroy() 
开发者ID:Jooyeshgar,项目名称:amir,代码行数:20,代码来源:class_bankaccounts.py

示例3: on_new_topfolder

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OK [as 别名]
def on_new_topfolder(self, widget, data=None):
        dlg = Gtk.FileChooserDialog(_("Create New Folder"), self.ui)
        dlg.set_action(Gtk.FileChooserAction.CREATE_FOLDER)
        dlg.set_local_only(True)
        dlg.add_buttons(_("Use Default"), Gtk.ResponseType.NONE, Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)

        response = dlg.run()
        if response == Gtk.ResponseType.OK:
            path = dlg.get_filename()
            self.__createFolder(os.path.basename(path), None, path)
            self.app.monitor.add_watch(path)
            dlg.destroy()
            self.app.config_altered(True)
        elif response == Gtk.ResponseType.NONE:
            dlg.destroy()
            name = self.__getNewItemName("Folder")
            self.__createFolder(name, None)
            self.app.config_altered(True)
        else:
            dlg.destroy() 
开发者ID:autokey,项目名称:autokey,代码行数:22,代码来源:configwindow.py

示例4: export_selected

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OK [as 别名]
def export_selected(self):
        def to_csv(value):
            if value is None:
                return ''
            elif isinstance(value, memoryview):
                return ''
            return str(value)

        dlg = Gtk.FileChooserDialog(
            'Export Selection', self.win, Gtk.FileChooserAction.SAVE,
            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
             Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
        file_filter = Gtk.FileFilter()
        file_filter.set_name('CSV files')
        file_filter.add_mime_type('text/csv')
        dlg.add_filter(file_filter)
        dlg.set_current_name('export.csv')
        if dlg.run() == Gtk.ResponseType.ACCEPT:
            with open(dlg.get_filename(), 'w') as f:
                writer = csv.writer(f)
                for row in self._selection.get_export_data():
                    writer.writerow(list(map(to_csv, row)))
        dlg.destroy() 
开发者ID:andialbrecht,项目名称:runsqlrun,代码行数:25,代码来源:results.py

示例5: on_download_to_activated

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OK [as 别名]
def on_download_to_activated(self, menu_item):
        '''下载文件/目录到指定的文件夹里.'''
        tree_paths = self.iconview.get_selected_items()
        if not tree_paths:
            return

        dialog = Gtk.FileChooserDialog(_('Save to...'), self.app.window,
                Gtk.FileChooserAction.SELECT_FOLDER,
                (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                 Gtk.STOCK_OK, Gtk.ResponseType.OK))
        response = dialog.run()
        if response != Gtk.ResponseType.OK:
            dialog.destroy()
            return
        dirname = dialog.get_filename()
        dialog.destroy()

        pcs_files = [self.get_pcs_file(p) for p in tree_paths]
        self.app.blink_page(self.app.download_page)
        self.app.download_page.add_tasks(pcs_files, dirname) 
开发者ID:XuShaohua,项目名称:bcloud,代码行数:22,代码来源:IconWindow.py

示例6: add_file_task

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OK [as 别名]
def add_file_task(self, dir_name=None):
        '''添加上传任务, 会弹出一个选择文件的对话框'''
        file_dialog = Gtk.FileChooserDialog(_('Choose Files..'),
                self.app.window, Gtk.FileChooserAction.OPEN,
                (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                 Gtk.STOCK_OK, Gtk.ResponseType.OK))
        file_dialog.set_modal(True)
        file_dialog.set_select_multiple(True)
        file_dialog.set_default_response(Gtk.ResponseType.OK)
        response = file_dialog.run()
        if response != Gtk.ResponseType.OK:
            file_dialog.destroy()
            return
        source_paths = file_dialog.get_filenames()
        file_dialog.destroy()
        if source_paths:
            self.upload_files(source_paths, dir_name) 
开发者ID:XuShaohua,项目名称:bcloud,代码行数:19,代码来源:UploadPage.py

示例7: add_folder_task

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OK [as 别名]
def add_folder_task(self, dir_name=None):
        '''添加上传任务, 会弹出一个选择文件夹的对话框'''
        folder_dialog = Gtk.FileChooserDialog(_('Choose Folders..'),
                self.app.window, Gtk.FileChooserAction.SELECT_FOLDER,
                (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                 Gtk.STOCK_OK, Gtk.ResponseType.OK))
        folder_dialog.set_modal(True)
        folder_dialog.set_select_multiple(True)
        folder_dialog.set_default_response(Gtk.ResponseType.OK)
        folder_dialog.set_current_folder(Config.HOME_DIR)
        response = folder_dialog.run()
        if response != Gtk.ResponseType.OK:
            folder_dialog.destroy()
            return
        source_paths = folder_dialog.get_filenames()
        folder_dialog.destroy()
        if source_paths:
            self.upload_files(source_paths, dir_name) 
开发者ID:XuShaohua,项目名称:bcloud,代码行数:20,代码来源:UploadPage.py

示例8: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OK [as 别名]
def __init__(self, title, window=None, ok_button=True, cancel_button=True):
        Gtk.Dialog.__init__(self, title, window)
        self.set_modal(True)
        self.set_destroy_with_parent(True)
        if ok_button:
            self.add_button(Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)
        if cancel_button:
            self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
        self.set_default_response(Gtk.ResponseType.ACCEPT)
        self.set_resizable(False)
        self.set_icon_from_file(comun.ICON)
        self.connect('realize', self.on_realize)
        self.init_ui()
        self.show_all() 
开发者ID:atareao,项目名称:lplayer,代码行数:16,代码来源:basedialog.py

示例9: display

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OK [as 别名]
def display(self):
        """
        Constructs the GUI, consisting of a message, and fields to enter the
        name and password (commented out for now)
        """


        # GUI setup:
        dialog = Gtk.Dialog(_("Download media tool"),
                                self.uistate.window,
                                Gtk.DialogFlags.MODAL|
                                Gtk.DialogFlags.DESTROY_WITH_PARENT,
                                (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
                                 Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
        label = Gtk.Label(_("Make sure you are connected to the internet "
                            "before starting this tool."))
        label.set_line_wrap(True)
        vbox = Gtk.VBox()
        vbox.pack_start(label, True, True, 0)

#        hbox1 = Gtk.HBox()
#        label_name = Gtk.Label(_("Name") + ":")
#        self.name_entry = Gtk.Entry()
#        self.name_entry.set_text("%s" % name)
#        hbox1.pack_start(label_name, False, False, 0)
#        hbox1.pack_start(self.name_entry, True, True, 0)
#        vbox.pack_start(hbox1, False)
#
#        hbox2 = Gtk.HBox()
#        label_password = Gtk.Label(_("Password") + ":")
#        self.password_entry = Gtk.Entry()
#        self.password_entry.set_text("%s" % password)
#        hbox2.pack_start(label_password, False, False, 0)
#        hbox2.pack_start(self.password_entry, True, True, 0)
#        vbox.pack_start(hbox2, False)

        dialog.vbox.set_spacing(10)
        dialog.vbox.pack_start(vbox, True, True, 0)
        dialog.show_all()
        return dialog 
开发者ID:gramps-project,项目名称:addons-source,代码行数:42,代码来源:DownloadMedia.py

示例10: save_html

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OK [as 别名]
def save_html(self, data):
        html = data
        chooser = Gtk.FileChooserDialog("Export HTML", None, Gtk.FileChooserAction.SAVE,
                                        (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                                         Gtk.STOCK_OK, Gtk.ResponseType.OK))
        self.set_file_chooser_path(chooser)
        html_filter = Gtk.FileFilter()
        html_filter.set_name("HTML Files")
        html_filter.add_pattern("*.html")
        html_filter.add_pattern("*.htm")
        chooser.set_do_overwrite_confirmation(True)
        chooser.add_filter(html_filter)
        response = chooser.run()
        if response == Gtk.ResponseType.OK:
            file_name = chooser.get_filename()
            if not file_name.endswith(".html"):
                file_name += ".html"
            file = open(file_name, 'w')
            soup = BeautifulSoup(html, "lxml")
            
            file.write(soup.prettify())
            file.close()
        elif response == Gtk.ResponseType.CANCEL:
            pass
        chooser.destroy()
        self.window.set_sensitive(True) 
开发者ID:jamiemcg,项目名称:Remarkable,代码行数:28,代码来源:RemarkableWindow.py

示例11: on_button_clicked

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OK [as 别名]
def on_button_clicked(self, sender):
        """Shows the filesystem explorer to choose a new file

        @param sender: not used, only here for signal compatibility
        """
        self.chooser = Gtk.FileChooserDialog(
            title=None,
            action=Gtk.FileChooserAction.SAVE,
            buttons=(Gtk.STOCK_CANCEL,
                     Gtk.ResponseType.CANCEL,
                     Gtk.STOCK_OK,
                     Gtk.ResponseType.OK))
        self.chooser.set_default_response(Gtk.ResponseType.OK)
        # set default file as the current self.path
        dirname, basename = os.path.split(self.textbox.get_text())
        self.chooser.set_current_name(basename)
        self.chosser.set_current_folder(dirname)

        # filter files
        afilter = Gtk.FileFilter()
        afilter.set_name("All files")
        afilter.add_pattern("*")
        self.chooser.add_filter(afilter)
        afilter = Gtk.FileFilter()
        afilter.set_name("XML files")
        afilter.add_mime_type("text/plain")
        afilter.add_pattern("*.xml")
        self.chooser.add_filter(afilter)
        response = self.chooser.run()
        if response == Gtk.ResponseType.OK:
            self.textbox.set_text(self.chooser.get_filename())
        self.chooser.destroy() 
开发者ID:getting-things-gnome,项目名称:gtg,代码行数:34,代码来源:path.py

示例12: getUserTextDialog

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OK [as 别名]
def getUserTextDialog(parent, title, description):
    dialog = Gtk.Dialog(title, parent,
                        Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
                        (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                         Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
    dialog.set_resizable(False)
    dialog.set_size_request(400, -1)

    vbx = Gtk.VBox()
    label = Gtk.Label(description)
    label.set_xalign(0)
    vbx.pack_start(label, True, True, 5)
    textedit = Gtk.Entry()
    textedit.connect("activate", lambda p: dialog.response(Gtk.ResponseType.ACCEPT))
    vbx.pack_end(textedit, True, True, 5)

    hbx = Gtk.HBox()
    hbx.pack_start(vbx, True, True, 10)

    dialog.get_content_area().pack_start(hbx, True, True, 5)
    dialog.show_all()
    if (dialog.run() == Gtk.ResponseType.ACCEPT):
        result = textedit.get_text()
    else:
        result = None
    dialog.destroy()
    return result 
开发者ID:pychess,项目名称:pychess,代码行数:29,代码来源:prompttext.py

示例13: on_pick_date

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OK [as 别名]
def on_pick_date(button, date_entry):
    # Parse the existing date
    date = date_entry.get_text()
    year, month, day = parseDateTag(date)

    # Prepare the date of the picker
    calendar = Gtk.Calendar()
    curyear, curmonth, curday = calendar.get_date()
    year = curyear if year is None else year
    month = curmonth if month is None else month - 1
    day = curday if day is None else day
    calendar.select_month(month, year)
    calendar.select_day(day)

    # Show the dialog
    dialog = Gtk.Dialog(_("Pick a date"),
                        None,
                        Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
                        (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))

    sw = Gtk.ScrolledWindow()
    sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
    sw.add(calendar)

    dialog.get_content_area().pack_start(sw, True, True, 0)
    dialog.resize(300, 200)
    dialog.show_all()

    response = dialog.run()
    dialog.destroy()

    if response == Gtk.ResponseType.ACCEPT:
        year, month, day = calendar.get_date()
        date_entry.set_text("%04d.%02d.%02d" % (year, month + 1, day)) 
开发者ID:pychess,项目名称:pychess,代码行数:36,代码来源:gameinfoDialog.py

示例14: on_btBrowse_clicked

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OK [as 别名]
def on_btBrowse_clicked(self, *a):
		"""
		Display folder browser dialog to browse for folder... folder.
		Oh god, this new terminology sucks...
		"""
		if not self.is_new: return
		# Prepare dialog
		d = Gtk.FileChooserDialog(
			_("Select Folder for new Folder"),	# fuck me...
			self["editor"],
			Gtk.FileChooserAction.SELECT_FOLDER,
			(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
			Gtk.STOCK_OK, Gtk.ResponseType.OK))
		# Set default path to home directory
		d.set_current_folder(os.path.expanduser("~"))
		# Get response
		if d.run() == Gtk.ResponseType.OK:
			self["vpath"].set_text(d.get_filename())
			if len(self["vid"].get_text().strip()) == 0:
				# ID is empty, fill it with last path element
				try:
					lpl = os.path.split(d.get_filename())[-1]
					id = RE_GEN_ID.search(lpl).group(0).lower()
					self["vid"].set_text(id)
				except AttributeError:
					# Can't regexp anything
					pass
		d.destroy() 
开发者ID:kozec,项目名称:syncthing-gtk,代码行数:30,代码来源:foldereditor.py

示例15: settings_dialog

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OK [as 别名]
def settings_dialog(self, widget):
    """Shows applet settings dialog."""
    self.dialog = gtk.Dialog(
      "Settings",
      None,
      0,
      (gtk.STOCK_CANCEL, gtk.ResponseType.CANCEL,
       gtk.STOCK_OK, gtk.ResponseType.OK)
    )

    self.builder = gtk.Builder()
    self.builder.add_from_file("/usr/lib/twitch-indicator/twitch-indicator.glade")

    self.builder.get_object("twitch_username").set_text(self.settings.get_string("twitch-username"))
    self.builder.get_object("show_notifications").set_active(self.settings.get_boolean("enable-notifications"))
    self.builder.get_object("refresh_interval").set_value(self.settings.get_int("refresh-interval"))

    self.box = self.dialog.get_content_area()
    self.box.add(self.builder.get_object("grid1"))
    self.response = self.dialog.run()

    if self.response == gtk.ResponseType.OK:
      self.settings.set_string("twitch-username", self.builder.get_object("twitch_username").get_text())
      self.settings.set_boolean("enable-notifications", self.builder.get_object("show_notifications").get_active())
      self.settings.set_int("refresh-interval", self.builder.get_object("refresh_interval").get_value_as_int())
    elif self.response == gtk.ResponseType.CANCEL:
      pass

    self.dialog.destroy() 
开发者ID:rolandasb,项目名称:twitch-indicator,代码行数:31,代码来源:run.py


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