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


Python BooleanVar.set方法代码示例

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


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

示例1: __init__

# 需要导入模块: from tkinter import BooleanVar [as 别名]
# 或者: from tkinter.BooleanVar import set [as 别名]
class KRCCModule:
  __metaclass__ = ABCMeta

  def __init__(self):
    self._terminate = BooleanVar(False)
    self._id = StringVar(False)

  @property
  def terminate(self):
    return self._terminate.get()

  @terminate.setter
  def terminate(self, value):
    self._terminate.set(value)

  @property
  def id(self):
    return self._id.get()

  @id.setter
  def id(self, value):
    self._id.set(value)

  @abstractproperty
  def name(self):
    pass

  @abstractmethod
  def run(self):
    pass
开发者ID:jsartisohn,项目名称:krpc_scripts,代码行数:32,代码来源:krcc_module.py

示例2: test_invalid_value_domain

# 需要导入模块: from tkinter import BooleanVar [as 别名]
# 或者: from tkinter.BooleanVar import set [as 别名]
 def test_invalid_value_domain(self):
     false = 0 if self.root.wantobjects() else "0"
     v = BooleanVar(self.root, name="name")
     with self.assertRaises(TclError):
         v.set("value")
     self.assertEqual(self.root.globalgetvar("name"), false)
     self.root.globalsetvar("name", "value")
     with self.assertRaises(ValueError):
         v.get()
     self.root.globalsetvar("name", "1.0")
     with self.assertRaises(ValueError):
         v.get()
开发者ID:Cartmanfku,项目名称:cpython,代码行数:14,代码来源:test_variables.py

示例3: test_set

# 需要导入模块: from tkinter import BooleanVar [as 别名]
# 或者: from tkinter.BooleanVar import set [as 别名]
 def test_set(self):
     true = 1 if self.root.wantobjects() else "1"
     false = 0 if self.root.wantobjects() else "0"
     v = BooleanVar(self.root, name="name")
     v.set(True)
     self.assertEqual(self.root.globalgetvar("name"), true)
     v.set("0")
     self.assertEqual(self.root.globalgetvar("name"), false)
     v.set(42)
     self.assertEqual(self.root.globalgetvar("name"), true)
     v.set(0)
     self.assertEqual(self.root.globalgetvar("name"), false)
     v.set("on")
     self.assertEqual(self.root.globalgetvar("name"), true)
开发者ID:Cartmanfku,项目名称:cpython,代码行数:16,代码来源:test_variables.py

示例4: Preferences

# 需要导入模块: from tkinter import BooleanVar [as 别名]
# 或者: from tkinter.BooleanVar import set [as 别名]
class Preferences(Frame):
    def __init__(self, client):
        # Basic setup
        super(Preferences, self).__init__()
        self.client = client

        # Setup the variables used
        self.echo_input = BooleanVar()
        self.echo_input.set(self.client.config['UI'].getboolean('echo_input'))
        self.echo_input.trace("w", self.echo_handler)
        self.logging = BooleanVar()
        self.logging.set(self.client.config['logging'].getboolean('log_session'))
        self.logging.trace('w', self.logging_handler)
        self.log_dir = self.client.config['logging']['log_directory']

        # Build the actual window and widgets
        prefs = Toplevel(self)
        prefs.wm_title("Preferences")
        echo_input_label = Label(prefs, text="Echo Input:")
        logging_label = Label(prefs, text='Log to file:')
        echo_checkbox = Checkbutton(prefs, variable=self.echo_input)
        logging_checkbox = Checkbutton(prefs, variable=self.logging)
        logging_button_text = 'Choose file...' if self.log_dir == "" else self.log_dir
        logging_button = Button(prefs, text=logging_button_text, command=self.logging_pick_location)

        # Pack 'em in.
        echo_input_label.grid(row=0, column=0)
        echo_checkbox.grid(row=0, column=1)
        logging_label.grid(row=1, column=0)
        logging_checkbox.grid(row=1, column=1)
        logging_button.grid(row=1, column=2)

    def logging_pick_location(self):
        location = askdirectory(initialdir="%UserProfile%\Documents\\")
        self.client.config['logging']['log_directory'] = location
        self.write_config()

    def echo_handler(self, arg1, arg2, mode):
        pprint(self.echo_input.get())
        self.client.config['UI']['echo_input'] = 'yes' if self.echo_input.get() else 'no'
        self.write_config()

    def logging_handler(self, arg1, arg2, mode):
        self.client.config['logging']['log_session'] = 'yes' if self.logging.get else 'no'
        self.write_config()

    def write_config(self, file='config.ini'):
        self.client.config.write(open(file, 'w'))
开发者ID:Errorprone85,项目名称:TEC-Client,代码行数:50,代码来源:preferences.py

示例5: ReplicatorMain

# 需要导入模块: from tkinter import BooleanVar [as 别名]
# 或者: from tkinter.BooleanVar import set [as 别名]
class ReplicatorMain(VerticalScrolledFrame):
    """The main class for the GUI of the application"""

    merge = None
    """This is the merge object of the application, it holds all settings for the merge operation"""
    filename = None
    """The name of the file containing the merge definition"""
    fr_src_dataset = None
    """The fram of the source dataset, contains a FrameCustomDataset descendant"""
    fr_dest_dataset = None
    """The fram of the source dataset, contains a FrameCustomDataset descendant"""
    suppress_errors = None
    """Do not show any errors"""
    _row_index = None
    """The current row in the dataset"""
    curr_mapping_frame = None
    """The currently selected mapping frame"""

    def __init__(self, _merge=None, _filename=None, *args, **kw):

        self.parent = Tk()

        # Init oneself

        super(ReplicatorMain, self).__init__(self.parent, bd=1, relief=SUNKEN, *args, **kw)
        self.grid(stick=(E, W, N, S))

        self.suppress_errors = None

        self.merge = _merge
        self.filename = _filename

        self.fr_src_dataset = None
        self.fr_dest_dataset = None

        self.grid()
        self.ip_address = StringVar()
        self._row_index = 0
        self.init_GUI()

        if _filename is not None and _merge is not None:
            # _merge._load_datasets()
            self._merge_to_gui()


        self.parent.columnconfigure(0, weight=1)
        self.parent.rowconfigure(0, weight=1)
        self.resize()

        self.parent.mainloop()

    def resize(self):
        """
        Resize the window, set the width what the internal windows need.
        """
        self._canvas.update_idletasks()
        self.fr_top_right.update_idletasks()
        self._canvas.config(width=self.interior.winfo_reqwidth() + 1, height=self.interior.winfo_reqheight())

    def on_dataset_columns_change(self, *args):
        # Columns have changed; force reload columns from structure
        self.fr_src_dataset.get_possible_references(True)
        self.fr_dest_dataset.get_possible_references(True)
        for curr_mapping in self.g_mappings.items:
            curr_mapping.fr_item.reload_references()


    def notify_task(self, _task, _progress):
        """Override as this is the top widget"""
        self.fr_Status_Bar.update_task(_task, _progress)

    def notify_messagebox(self, _title, _message, _kind=None):
        """Override as this is the top class, default is error."""
        if self.suppress_errors is None:
            if _kind == "message":
                messagebox.showinfo(_title, _message)
            elif _kind == "warning":
                messagebox.showwarning(_title, _message)
            else:
                messagebox.showerror(_title, _message)

    def on_post_merge_sql(self, *args):
        # Show post-merge-SQL dialog
        _wdw = Toplevel()
        _wdw.geometry('+400+400')
        _wdw.e = TextExtension(_wdw, textvariable=self.post_execute_sql)
        _wdw.e.pack()
        _wdw.e.focus_set()
        _wdw.transient(self.parent)
        _wdw.grab_set()
        self.parent.wait_window(_wdw)
        _wdw.e.unhook()
        del (_wdw)


    def on_src_connect(self, *args):
        """Event handler for when the source connection is set"""
        self.fr_mapping.src_dal = self.fr_dataset_src.dal

    def on_dest_connect(self, *args):
#.........这里部分代码省略.........
开发者ID:OptimalBPM,项目名称:qal,代码行数:103,代码来源:main_tk_replicator.py

示例6: FrameFlatfileDataset

# 需要导入模块: from tkinter import BooleanVar [as 别名]
# 或者: from tkinter.BooleanVar import set [as 别名]
class FrameFlatfileDataset(FrameCustomFileDataset):
    """
        Holds an instance of, and visually represents, a flatfile dataset.
        See qal.dataset.flatfile.FlatfileDataset
    """

    def __init__(self, _master, _dataset = None, _relief = None, _is_destination=None):
        super(FrameFlatfileDataset, self ).__init__(_master, _dataset, _relief, _is_destination=_is_destination)

        if _dataset is None:
            self.dataset = FlatfileDataset()

    def on_select(self):
        """Brings up a selector dialog, prompting the user to select a file,
        the relative path if the file is then saved to the filename property.
        Also, the base path is set.
        """
        self.select_file(_default_extension = ".csv", _file_types=[('.csv files', '.csv'), ('all files', '.*')])

    def init_widgets(self):
        # file selector
        self.btn_file_select=Button(self, text="Select file",command=self.on_select)
        self.btn_file_select.grid(column=0, row=0, columnspan=2)
        # filename
        self.filename, self.e_filename, self.l_filename = make_entry(self,"File name: ", 1)

        # delimiter
        self.delimiter, self.e_delimiter, self.l_delimiter = make_entry(self,"Delimiter: ", 2)

        # has_header
        self.l_has_header = ttk.Label(self, text="Has header: ")
        self.l_has_header.grid(column=0, row=3, sticky=W)
        self.has_header = BooleanVar()
        self.e_has_header = ttk.Checkbutton(self, variable=self.has_header)
        self.e_has_header.grid(column=1, row=3, sticky=W)

        # csv_dialect
        self.csv_dialect, self.e_csv_dialect, self.l_csv_dialect = make_entry(self,"CSV dialect: ", 4)

        # quoting
        self.quoting, self.e_quoting, self.l_quoting = make_entry(self, "Quoting: ", 5)

        # escapechar
        self.escapechar, self.e_escapechar, self.l_escapechar = make_entry(self, "Escape character: ", 6)

        # lineterminator
        self.lineterminator, self.e_lineterminator, self.l_lineterminator = make_entry(self, "Line terminator: ", 7)

        # quotechar
        self.quotechar, self.e_quotechar, self.l_quotechar = make_entry(self, "Quote character: ", 8)

        # skipinitialspace
        self.skipinitialspace, self.e_skipinitialspace, self.l_skipinitialspace = make_entry(self, "Skip initial space: ", 9)

    def read_from_dataset(self):
        super(FrameFlatfileDataset, self ).read_from_dataset()

        self.filename.set(empty_when_none(self.dataset.filename))
        self.delimiter.set(empty_when_none(self.dataset.delimiter))
        self.has_header.set(bool_to_binary_int(self.dataset.has_header))
        self.csv_dialect.set(empty_when_none(self.dataset.csv_dialect))
        self.quoting.set(empty_when_none(self.dataset.quoting))
        self.escapechar.set(empty_when_none(self.dataset.escapechar))
        self.lineterminator.set(empty_when_none(self.dataset.lineterminator))
        self.quotechar.set(empty_when_none(self.dataset.quotechar))
        self.skipinitialspace.set(empty_when_none(self.dataset.skipinitialspace))

    def write_to_dataset(self):
        super(FrameFlatfileDataset, self ).write_to_dataset()

        if self.dataset is None:
            self.dataset = FlatfileDataset()

        self.dataset.filename = self.filename.get()
        self.dataset.delimiter = self.delimiter.get()
        self.dataset.has_header = self.has_header.get()
        self.dataset.csv_dialect = self.csv_dialect.get()
        self.dataset.quoting = self.quoting.get()
        self.dataset.escapechar = self.escapechar.get()
        self.dataset.lineterminator = self.lineterminator.get()
        self.dataset.quotechar = self.quotechar.get()
        self.dataset.skipinitialspace = self.skipinitialspace.get()


    def reload(self):
        self.notify_task("Load file "+ self.dataset.filename, 10)
        self.dataset.load()
        self.notify_task("Loaded filed "+ self.dataset.filename + ".", 100)

    def get_possible_references(self, _force = None):

        if not self.dataset.field_names or _force == True:
            self.reload()

        self.references = self.dataset.field_names
        return self.dataset.field_names

    def check_reload(self):
        _filename = self.filename.get()
        if not os.path.isabs(_filename) and self.base_path is None:
#.........这里部分代码省略.........
开发者ID:OptimalBPM,项目名称:qal,代码行数:103,代码来源:frame_dataset_flatfile.py

示例7: FrameSpreadsheetDataset

# 需要导入模块: from tkinter import BooleanVar [as 别名]
# 或者: from tkinter.BooleanVar import set [as 别名]
class FrameSpreadsheetDataset(FrameCustomFileDataset):
    """
        Holds an instance of, and visually represents, a spreadsheet dataset.
        See qal.dataset.spreadsheet.SpreadsheetDataset
    """

    def __init__(self, _master, _dataset=None, _relief=None, _is_destination=None):
        super(FrameSpreadsheetDataset, self).__init__(_master, _dataset, _relief, _is_destination=_is_destination)

        if _dataset is None:
            self.dataset = SpreadsheetDataset()

    def on_select(self):
        """Brings up a selector dialog, prompting the user to select a file,
        the relative path if the file is then saved to the filename property.
        Also, the base path is set.
        """
        self.select_file(_default_extension=".xlsx", _file_types=[('.xlsx files', '.xlsx'), ('all files', '.*')])

    def init_widgets(self):
        # file selector
        self.btn_file_select = Button(self, text="Select file", command=self.on_select)
        self.btn_file_select.grid(column=0, row=0, columnspan=2)

        # filename
        self.filename, self.e_filename, self.l_filename = make_entry(self, "File name: ", 1)


        # delimiter
        self.delimiter, self.e_delimiter, self.l_delimiter = make_entry(self, "Delimiter: ", 2)

        # has_header
        self.l_has_header = ttk.Label(self, text="Has header: ")
        self.l_has_header.grid(column=0, row=3, sticky=W)
        self.has_header = BooleanVar()
        self.e_has_header = ttk.Checkbutton(self, variable=self.has_header)
        self.e_has_header.grid(column=1, row=3, sticky=W)

        # sheet_name
        self.sheet_name, self.e_sheet_name, self.l_sheet_name = make_entry(self, "Sheet name: ", 4)

        # x_offset
        self.x_offset, self.e_x_offset, self.l_x_offset = make_entry(self, "X offset: ", 5)


        # y_offset
        self.y_offset, self.e_y_offset, self.l_y_offset = make_entry(self, "Y offset: ", 6)


    def read_from_dataset(self):
        super(FrameSpreadsheetDataset, self).read_from_dataset()

        self.filename.set(empty_when_none(self.dataset.filename))
        self.has_header.set(bool_to_binary_int(self.dataset.has_header))
        self.sheet_name.set(empty_when_none(self.dataset.sheet_name))
        self.x_offset.set(empty_when_none(self.dataset.x_offset))
        self.y_offset.set(empty_when_none(self.dataset.y_offset))


    def write_to_dataset(self):
        super(FrameSpreadsheetDataset, self).write_to_dataset()

        if self.dataset is None:
            self.dataset = SpreadsheetDataset()

        self.dataset.filename = self.filename.get()
        self.dataset.delimiter = self.delimiter.get()
        self.dataset.has_header = binary_int_to_bool(self.has_header.get())

        self.dataset.sheet_name = self.sheet_name.get()
        if self.x_offset.get() == "":
            self.dataset.x_offset = None
        else:
            self.dataset.x_offset = int(self.x_offset.get())

        if self.y_offset.get() == "":
            self.dataset.y_offset = None
        else:
            self.dataset.y_offset = int(self.y_offset.get())

    def reload(self):
        self.notify_task("Load spreadsheet " + self.dataset.filename, 10)
        self.dataset.load()
        self.notify_task("Loaded spreadsheet " + self.dataset.filename + ".", 100)

    def get_possible_references(self, _force=None):

        if not self.dataset.field_names or _force == True:
            self.reload()

        self.references = self.dataset.field_names

        return self.dataset.field_names
开发者ID:OptimalBPM,项目名称:qal,代码行数:95,代码来源:frame_dataset_spreadsheet.py

示例8: OmxGui

# 需要导入模块: from tkinter import BooleanVar [as 别名]
# 或者: from tkinter.BooleanVar import set [as 别名]
class OmxGui(Frame):
   
   def __init__(self, parent, argv):
      
      Frame.__init__(self, parent, padding=(3,6,3,12), style="TFrame")
      
      self.parent = parent
      
      self.initData()
      
      self.initUI()
      
      if len(argv) > 1:
         try:
            self.updateAndPlayVideo(argv[1])
         except FileNotFoundError:
            self.logDebug('File Not Found')
      
   def initData(self):
      self.browseInitialDir = def_initialDir
      
      self.recentFile = def_recentFile
      
      self.menuOutputAudio = StringVar()
      self.menuOutputAudio.set(def_menuOutputAudio)
      
      self.menuVideoRefresh = BooleanVar()
      self.menuVideoRefresh.set(def_menuVideoRefresh)
      
      self.menuBgBlack = BooleanVar()
      self.menuBgBlack.set(def_menuBgBlack)
      
      self.maxRecentVideos = def_maxRecentVideos
      
      self.moreOptions = def_moreOptions
      
      self.playProcess = None

   def initUI(self):
      
      self.parent.title('OMX GUI')
      
      self.parent.bind("<Key>", self.keyEvt)
      
      # ---- STYLE ----
      
      Style().theme_use('default')

      Style().configure("TFrame", background="white")
      Style().configure("TButton", font="12", padding=(5,1,5,1), background="#4285F4", foreground="white")
      Style().configure("TEntry", font="12", padding=(5,3,5,2))
      Style().configure("TLabel", background="white")
      Style().map('TButton',
                 foreground=[('pressed', 'white'), ('active', 'white')],
                 background=[('pressed', '!disabled', '#3367d6'), ('active', '#3b78e7')],
                 highlightcolor=[('focus','#4285F4')],
                 relief=[('pressed', '!disabled', 'flat')])
      Style().configure('Treeview', foreground='#333', background="white", highlightthickness='0')
      Style().map('Treeview',
                 foreground=[('focus', '#000')],
                 background=[('focus', '#F5F5F5')])

      # ---- MENU ----
      self.menubar = menubar = MenuBar(self, self.parent)
      
      # ---- TREE ----
      self.filesTree = filesTree = FilesTree(self)
      self.filesTree.loadRecentFile()
      
      # ---- BUTTONS ----
      bBrowse = Button(self, text=_("browse"), width="6", command=self.openVideo)
      bPlay = Button(self, text=_("play"), width="6", command=self.playVideo)
      
      # ---- GRID ----
      self.grid(column=0, row=0, sticky=(N, E, W, S))
      filesTree.grid(column=0, row=0, columnspan=2, rowspan=2, sticky=(N,W,E))
      bBrowse.grid(column=0, row=2, sticky=(N,W))
      bPlay.grid(column=0, row=2, sticky=(N,W), padx=70)
      
      self.parent.columnconfigure(0, weight=1)
      self.parent.rowconfigure(0, weight=1)
      self.columnconfigure(0, weight=1)
      self.columnconfigure(1, weight=1)
      self.rowconfigure(0, weight=1)
      self.rowconfigure(1, weight=1)
      
      self.centerWindow()
      
   def centerWindow(self):
      self.parent.update_idletasks()
      
      w = self.parent.winfo_reqwidth() + 20
      h = self.parent.winfo_reqheight() + 20
      sw = self.parent.winfo_screenwidth()
      sh = self.parent.winfo_screenheight()

      x = (sw - w)/4
      y = (sh - h)/4
      self.parent.geometry("%dx%d+%d+%d" % (w, h, x, y))
      self.parent.resizable(False,False)
#.........这里部分代码省略.........
开发者ID:frama986,项目名称:omx-simple-interface,代码行数:103,代码来源:guiController.py

示例9: FrameMapping

# 需要导入模块: from tkinter import BooleanVar [as 别名]
# 或者: from tkinter.BooleanVar import set [as 别名]
class FrameMapping(FrameCustomItem):
    """Holds and visualizes a Map between two columns of different datasets"""
    row_index = None

    is_key = None
    src_reference = None
    src_datatype = None
    src_cast_to = None
    dest_table = None
    curr_data = None
    curr_raw_data = None
    mapping = None

    preview = None
    dest_reference = None

    def __init__(self, _master, _mapping = None,
                 _on_get_source_references = None,
                 _on_get_destination_references = None,
                 _on_select = None):
        super(FrameMapping, self).__init__(_master)


        # Add monitored variables.
        self.is_key = BooleanVar()
        self.src_reference = StringVar()
        self.src_datatype = StringVar()
        self.curr_data = StringVar()

        self.result_cast_to = StringVar()
        self.preview = StringVar()

        self.dest_reference = StringVar()

        self.on_get_source_references = _on_get_source_references
        self.on_get_destination_references = _on_get_destination_references

        self.on_select = _on_select
        self.init_widgets()

        self.mapping = _mapping



        if _mapping is not None:
            self.mapping_to_gui()


    def mapping_to_gui(self):

        self.src_reference.set(str(empty_when_none(self.mapping.src_reference)))
        self.dest_reference.set(str(empty_when_none(self.mapping.dest_reference)))
        self.src_datatype.set(self.mapping.src_datatype)
        self.is_key.set(bool_to_binary_int(self.mapping.is_key))

    def gui_to_mapping(self):

        self.mapping.src_reference = self.src_reference.get()
        self.mapping.dest_reference = self.dest_reference.get()

        self.mapping.is_key = binary_int_to_bool(self.is_key.get())

    def reload_references(self):
        self.cb_source_ref['values'] = self.get_source_references()
        self.cb_dest_ref['values'] = self.get_destination_references()


    def get_source_references(self, _force = None):
        if self.on_get_source_references:
            return self.on_get_source_references(_force)

    def get_destination_references(self, _force = None):
        if self.on_get_destination_references:
            return self.on_get_destination_references( _force)


    def on_change_source_ref(self, *args):
        # reload dataset.
        pass


    def init_widgets(self):

        """Init all widgets"""

        # Source reference
        self.cb_source_ref = ttk.Combobox(self, textvariable=self.src_reference, state='normal')
        self.cb_source_ref['values'] = self.get_source_references()
        self.cb_source_ref.pack(side=LEFT, fill=X, expand=1)


        # Data type label
        self.l_data_type = ttk.Label(self, textvariable=self.src_datatype, width=8)
        self.src_datatype.set("Not set")

        self.l_data_type.pack(side=LEFT)

        # Dest reference
        self.cb_dest_ref = ttk.Combobox(self, textvariable=self.dest_reference, state='normal')
        self.cb_dest_ref['values'] = self.get_destination_references()
#.........这里部分代码省略.........
开发者ID:OptimalBPM,项目名称:qal,代码行数:103,代码来源:frame_mapping.py

示例10: GrepDialog

# 需要导入模块: from tkinter import BooleanVar [as 别名]
# 或者: from tkinter.BooleanVar import set [as 别名]
class GrepDialog(SearchDialogBase):

    title = "Find in Files Dialog"
    icon = "Grep"
    needwrapbutton = 0

    def __init__(self, root, engine, flist):
        SearchDialogBase.__init__(self, root, engine)
        self.flist = flist
        self.globvar = StringVar(root)
        self.recvar = BooleanVar(root)

    def open(self, text, searchphrase, io=None):
        SearchDialogBase.open(self, text, searchphrase)
        if io:
            path = io.filename or ""
        else:
            path = ""
        dir, base = os.path.split(path)
        head, tail = os.path.splitext(base)
        if not tail:
            tail = ".py"
        self.globvar.set(os.path.join(dir, "*" + tail))

    def create_entries(self):
        SearchDialogBase.create_entries(self)
        self.globent = self.make_entry("In files:", self.globvar)[0]

    def create_other_buttons(self):
        f = self.make_frame()[0]

        btn = ui.Checkbutton(f, variable=self.recvar,
                             text="Recurse down subdirectories")
        btn.pack(side="top", fill="both")
        self.recvar.set(True)
        if not ui.using_ttk:
            btn.select()

    def create_command_buttons(self):
        SearchDialogBase.create_command_buttons(self)
        self.make_button("Search Files", self.default_command, 1)

    def default_command(self, event=None):
        prog = self.engine.getprog()
        if not prog:
            return
        path = self.globvar.get()
        if not path:
            self.top.bell()
            return
        from idlelib.OutputWindow import OutputWindow  # leave here!
        save = sys.stdout
        try:
            sys.stdout = OutputWindow(self.flist)
            self.grep_it(prog, path)
        finally:
            sys.stdout = save

    def grep_it(self, prog, path):
        dir, base = os.path.split(path)
        list = self.findfiles(dir, base, self.recvar.get())
        list.sort()
        self.close()
        pat = self.engine.getpat()
        print("Searching %r in %s ..." % (pat, path))
        hits = 0
        try:
            for fn in list:
                try:
                    with open(fn, errors='replace') as f:
                        for lineno, line in enumerate(f, 1):
                            if line[-1:] == '\n':
                                line = line[:-1]
                            if prog.search(line):
                                sys.stdout.write("%s: %s: %s\n" %
                                                 (fn, lineno, line))
                                hits += 1
                except OSError as msg:
                    print(msg)
            print(("Hits found: %s\n"
                  "(Hint: right-click to open locations.)"
                  % hits) if hits else "No hits.")
        except AttributeError:
            # Tk window has been closed, OutputWindow.text = None,
            # so in OW.write, OW.text.insert fails.
            pass

    def findfiles(self, dir, base, rec):
        try:
            names = os.listdir(dir or os.curdir)
        except OSError as msg:
            print(msg)
            return []
        list = []
        subdirs = []
        for name in names:
            fn = os.path.join(dir, name)
            if os.path.isdir(fn):
                subdirs.append(fn)
            else:
#.........这里部分代码省略.........
开发者ID:Darriall,项目名称:idle,代码行数:103,代码来源:GrepDialog.py

示例11: __init__

# 需要导入模块: from tkinter import BooleanVar [as 别名]
# 或者: from tkinter.BooleanVar import set [as 别名]
class take_data:
    '''
    '''

    def __init__(self, pype, toplevel=False, filename=False, num_sequences=10,
                 run_tag=''):
        '''
        '''
        self.pype = pype
        self.toplevel = toplevel

        self.keep_runningVar = BooleanVar(value=True)
        self.extend_runVar = BooleanVar(value=False)
        self.run_typeVar = StringVar(value="/tmp/")
        self.run_tagVar = StringVar(value=run_tag)
        self.num_sequencesVar = IntVar(value=num_sequences)
        self.sequence_spacingVar = DoubleVar(value=0)
        self.len_sequenceVar = DoubleVar()
        self.stateVar = StringVar(value='done')
        self.conf_filename = StringVar(value='')
        self.params = {}
        self.runthread = multiprocessing.Process()

        self._GetParamFuncs()
        if toplevel:
            self._BuildGui()

    def _BuildGui(self):
        '''
            Setup all of the buttons and user entries
        '''
        # Data Location
        row = 0
        Label(self.toplevel, text='-'*20+'Data Location'+'-'*20).grid(row=row,
                                                        columnspan=3, column=0)
        row += 1
        Label(self.toplevel, text='/data').grid(row=row, column=0, sticky='E')
        run_type_options = ["/tmp/", "/commissioning/", "/runs/"]
        OptionMenu(self.toplevel, self.run_typeVar, *run_type_options).grid(
                                             row=row, column=1, sticky='EW')
        Entry(self.toplevel, textvariable=self.run_tagVar).grid(row=row,
                                                                column=2)
        Checkbutton(self.toplevel, text="Extend if Exists",
                    variable=self.extend_runVar).grid(row=row, column=3)
        row += 1
        Label(self.toplevel, text="(raid location)").grid(row=row, column=0, sticky='E')
        Label(self.toplevel, text="(run type)").grid(row=row, column=1)
        Label(self.toplevel, text="(run tag)").grid(row=row, column=2)
        row += 1

        # Acquisition Cycle Details
        Label(self.toplevel, text='-'*20+'Acquisition Cycles'+'-'*20).grid(row=row,
                                                        columnspan=3, column=0)
        row += 1
        Label(self.toplevel, text='Number of Sequences').grid(row=row,
                                                              column=0)
        Entry(self.toplevel, textvariable=self.num_sequencesVar).grid(row=row,
                                                                      column=1)
        row += 1
        Label(self.toplevel, text='Delay Between').grid(row=row, column=0)
        Entry(self.toplevel, textvariable=self.sequence_spacingVar).grid(row=row, column=1)
        Label(self.toplevel, text='[s]').grid(row=row, column=2, sticky='W')
        row += 1
        builtins_list = ['default_run', 'noise_analysis_run']
        self.conf_filename.set(builtins_list[0])
        Button(self.toplevel, text='Load Builtin Run Def',
               command=self._GetParamFuncs).grid(row=row, column=0)
        OptionMenu(self.toplevel, self.conf_filename, *builtins_list).grid(
            row=row, column=1)
        self.conf_filename.set(builtins_list[0])
        row += 1
        Label(self.toplevel, text='Load Custom Run Def').grid(row=row,
                                                              column=0)
        Button(self.toplevel, text="find file", command=self._ParamFuncFile
               ).grid(row=row, column=1)
        row += 1

        # Mantis Settings
        Label(self.toplevel, text='-'*20+'Mantis Settings'+'-'*20).grid(row=row,
                                                        columnspan=3, column=0)
        row += 1
        Label(self.toplevel, text='(Empty fields use default values)').grid(row=row,
                                                        columnspan=3, column=0)
        row += 1
        Label(self.toplevel, text='Digitization Time').grid(row=row, column=0)
        Entry(self.toplevel, textvariable=self.len_sequenceVar).grid(row=row,
                                                                     column=1)
        Label(self.toplevel, text='[ms]').grid(row=row, column=2, sticky='W')
        row += 1

        Button(self.toplevel, text="Start Run", command=self.DoRun
               ).grid(row=row, column=0)
        Button(self.toplevel, text="ABORT", command=self._Abort, bg='red'
               ).grid(row=row, column=1)
        Label(self.toplevel, textvariable=self.stateVar).grid(row=row, column=2)

    def _ParamFuncFile(self):
        '''
        '''
        self.conf_filename.set(askopenfilename())
#.........这里部分代码省略.........
开发者ID:project8,项目名称:Pypeline,代码行数:103,代码来源:data_run_gui.py

示例12: overwriteWindow

# 需要导入模块: from tkinter import BooleanVar [as 别名]
# 或者: from tkinter.BooleanVar import set [as 别名]
def overwriteWindow(root):
    '''Creates the window for deciding to overwrite or not.'''

    def toggle(*args):    
        setState(choice.get(), 'disabled', [gen2Label, gen3Label,
                                            gen2Button, gen3Button,
                                            gen2Entry, gen3Entry])
        setState(not choice.get(), 'disabled', [warningLabel])

        if not choice.get() and (gen2Text.get() == '' or gen3Text.get() == ''):
            navFrame.disable('next', True)
        else:
            navFrame.disable('next', False)

    def gen2Dialog():
        askSave = filedialog.asksaveasfilename
        file = askSave(title='Gen II Save File', initialdir=root.dir,
                       filetypes=[('GB Save', '.sav'), ('All Files', '.*')],
                       defaultextension='.sav')
        if file != '':
            gen2Text.set(file)
            gen2Entry.after_idle(gen2Entry.xview_moveto, 1)
            root.dir = getDir(file)

    def gen3Dialog():
        askSave = filedialog.asksaveasfilename
        file = askSave(title='Gen III Save File', initialdir=root.dir,
                       filetypes=[('GBA Save', '.sav'), ('All Files', '.*')],
                       defaultextension='.sav')
        if file != '':
            gen3Text.set(file)
            gen3Entry.after_idle(gen3Entry.xview_moveto, 1)
            root.dir = getDir(file)

    def nextPage():
        global newGen2, newGen3, oldGen2, oldGen3

        if choice.get():
            newGen2 = oldGen2
            newGen3 = oldGen3
        else:
            newGen2 = gen2Entry.get()
            newGen3 = gen3Entry.get()

        root.nextPage()

    baseFrame = ttk.Frame(root)
    baseFrame.rowconfigure(0, weight=1)
    baseFrame.columnconfigure(0, weight=1)
    
    
    mainFrame = ttk.Frame(baseFrame, padding=MAIN_PAD)
    mainFrame.grid(row=0, column=0, sticky='ns')
    mainFrame.rowconfigure(0, weight=2)
    mainFrame.rowconfigure(3, weight=1)

    instrText = 'Select whether to overwrite the original save files, or to create new save files.'
    instrLabel = ttk.Label(mainFrame, text=instrText)
    instrLabel.grid(row=0, column=0)


    choiceFrame = ttk.Frame(mainFrame)
    choiceFrame.grid(row=1, column=0)

    choice = BooleanVar(value=True)
    choice1Radio = ttk.Radiobutton(choiceFrame, text='Overwrite',
                                   variable=choice, command=toggle,
                                   value=True)
    choice1Radio.grid(row=0, column=0, pady=5, sticky='w')

    warningText = 'WARNING! Once new data is created, this program can not recover old save data.'
    warningLabel = ttk.Label(choiceFrame, text=warningText, wraplength=300)
    warningLabel.grid(row=1, column=0, pady=5)
    
    choice2Radio = ttk.Radiobutton(choiceFrame, text='Do not overwrite',
                                   variable=choice, command=toggle,
                                   value=False)
    choice2Radio.grid(row=2, column=0, pady=5, sticky='w')


    pickerFrame = ttk.Frame(mainFrame)
    pickerFrame.grid(row=2, column=0)

    gen2Label = ttk.Label(pickerFrame, text='New Gen II file:')
    gen2Label.grid(row=0, column=0, columnspan=2)
    
    gen2Button = ttk.Button(pickerFrame, text='To...', command=gen2Dialog)
    gen2Button.grid(row=1, column=0, sticky='e', padx=5, pady=5)

    gen2Text = StringVar(pickerFrame)
    gen2Text.trace('w', toggle)
    gen2Entry = ttk.Entry(pickerFrame, textvariable=gen2Text, state='readonly')
    gen2Entry.grid(row=1, column=1, sticky='w', padx=5, pady=5)

    gen3Label = ttk.Label(pickerFrame, text='New Gen III file:')
    gen3Label.grid(row=2, column=0, columnspan=2)
    
    gen3Button = ttk.Button(pickerFrame, text='To...', command=gen3Dialog)
    gen3Button.grid(row=3, column=0, sticky='e', padx=5, pady=5)

#.........这里部分代码省略.........
开发者ID:Sidnoea,项目名称:pokeBridge,代码行数:103,代码来源:gui.py

示例13: Plastey

# 需要导入模块: from tkinter import BooleanVar [as 别名]
# 或者: from tkinter.BooleanVar import set [as 别名]
class Plastey(Tk):

    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)

        # Set window title
        self.wm_title('Plastey Configurator')

        # Create GUI driven variables
        self._mode       = BooleanVar()
        self._base       = BooleanVar()
        self._comm       = BooleanVar()
        self._pass       = StringVar()
        self._addressed  = StringVar()
        self._connected  = StringVar()
        self._this_host  = StringVar()
        self._this_port  = StringVar()
        self._other_host = StringVar()
        self._other_port = StringVar()

        # Create GUI
        self._build_gui()

        # Set default values for GUI driven variables
        self._mode.set(MODE_SINGLE_PLAYER)
        self._base.set(BASE_OPENED_GEOMETRY)
        self._comm.set(COMM_SOCKET_SERVER)
        self._pass.set('')
        self._addressed.set(ADDR_HAVE_ADDRESS if check(COMM_THIS_HOST) else ADDR_NO_ADDRESS)
        self._connected.set(CONN_NOT_CONNECTED)
        self._this_host.set(COMM_THIS_HOST)
        self._this_port.set(COMM_THIS_PORT)
        self._other_host.set(COMM_THIS_HOST)
        self._other_port.set(COMM_OTHER_PORT)

        # Follow changes on password
        self._pass.trace('w', self._on_bind_address)

        # Create folder structures if they don't exists yet
        makedirs(FILE_TEMPORARY_FOLDER,  exist_ok=True)
        makedirs(FILE_PERMANENT_FOLDER,  exist_ok=True)
        makedirs(FILE_TEMP_SAVE_FOLDER,  exist_ok=True)
        makedirs(FILE_AUTO_SAVE_FOLDER,  exist_ok=True)
        #makedirs(FILE_TEMP_STATE_FOLDER, exist_ok=True)
        #makedirs(FILE_TEMP_FEEDS_FOLDER, exist_ok=True)


    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
    def _build_gui(self):
        # Create GUI sections
        row = 0
        col = 0

        # Warning text
        Label(master  = self,
              text    = WARN_TEXT,
              anchor  = WEST,
              justify = CENTER).grid(row     = row,
                                     column  = col,
                                     sticky  = NORTH_WEST,
                                     rowspan = 16)

        # Set column spacing
        self.columnconfigure(index = col,
                             pad   = GUI_SECTION_PAD_X)
        row  = 0
        col += 1

        # Game mode options
        Label(master = self,
              text   = 'Game Mode:').grid(row    = row,
                                          column = col,
                                          sticky = WEST)
        row += 1
        Radiobutton(master   = self,
                    text     = 'Single Player',
                    value    = MODE_SINGLE_PLAYER,
                    variable = self._mode).grid(row    = row,
                                                column = col,
                                                sticky = WEST)
        row += 1
        Radiobutton(master   = self,
                    text     = 'Multi Player',
                    value    = MODE_MULTI_PLAYER,
                    variable = self._mode).grid(row    = row,
                                                column = col,
                                                sticky = WEST)
        row += 1

        # Base object modes
        Label(master = self,
              text   = 'Base Object:').grid(row    = row,
                                            column = col,
                                            sticky = WEST)
        row += 1
        Radiobutton(master   = self,
                    text     = 'Plane mesh',
                    value    = BASE_OPENED_GEOMETRY,
                    variable = self._base).grid(row    = row,
#.........这里部分代码省略.........
开发者ID:kitchenbudapest,项目名称:vr,代码行数:103,代码来源:plastey.py

示例14: __init__

# 需要导入模块: from tkinter import BooleanVar [as 别名]
# 或者: from tkinter.BooleanVar import set [as 别名]
    def __init__(self, master, par=False):
        """
        GUI for selecting default parameters - will write parameters to file \
        of users choosing.

        :type master: Tk
        :param master: Tkinter window
        :type par: EQcorrscanParameters
        :param par: Default parameters to start-up with.
        """
        from tkinter import Label, Button, Entry, DoubleVar, StringVar, IntVar
        from tkinter import BooleanVar, OptionMenu, Checkbutton
        import tkMessageBox
        from eqcorrscan.utils import parameters
        from obspy import UTCDateTime
        import warnings

        # Set the default par, only if they don't already exist.
        if not par:
            par = parameters.EQcorrscanParameters([''], 2, 10, 4, 100, 2,
                                                  '1900-01-01', '2300-01-01',
                                                  '', 'seishub', 4, False, '',
                                                  'jpg', False, 8, 'MAD', 6)
        # Callback functions for all variables (ugly)

        def update_template_names(*args):
            par.template_names = [name.strip() for name in
                                  template_names.get().split(',')]
            template_names.set(', '.join(par.template_names))

        def update_lowcut(*args):
            par.lowcut = lowcut.get()
            lowcut.set(par.lowcut)

        def update_highcut(*args):
            par.highcut = highcut.get()
            if par.highcut >= 0.5 * par.samp_rate:
                msg = ('Highcut must be less than the Nyquist, setting to ' +
                       str((par.samp_rate / 2.0) - 1))
                tkMessageBox.showwarning(title="Nyquist error",
                                         message=msg)
                par.highcut = (par.samp_rate / 2.0) - 1
            highcut.set(par.highcut)

        def update_filt_order(*args):
            par.filt_order = filt_order.get()
            filt_order.set(par.filt_order)

        def update_samp_rate(*args):
            par.samp_rate = samp_rate.get()
            if par.highcut >= 0.5 * par.samp_rate:
                msg = ('Highcut must be less than the Nyquist, setting to ' +
                       str((par.samp_rate / 2.0) - 1))
                tkMessageBox.showwarning(title="Nyquist error",
                                         message=msg)
                par.highcut = (par.samp_rate / 2.0) - 1
                highcut.set(par.highcut)
            samp_rate.set(par.samp_rate)

        def update_debug(*args):
            par.debug = debug.get()
            debug.set(par.debug)

        def update_startdate(*args):
            par.startdate = UTCDateTime(startdate.get())
            startdate.set(str(par.startdate))

        def update_enddate(*args):
            par.enddate = UTCDateTime(enddate.get())
            enddate.set(str(par.enddate))

        def update_archive(*args):
            par.archive = archive.get()
            archive.set(par.archive)

        def update_arc_type(*args):
            par.arc_type = arc_type.get()
            arc_type.set(par.arc_type)

        def update_cores(*args):
            par.cores = cores.get()
            cores.set(par.cores)

        def update_plotvar(*args):
            par.plotvar = plotvar.get()
            plotvar.set(par.plotvar)

        def update_plot_format(*args):
            par.plot_format = plot_format.get()
            plot_format.set(par.plot_format)

        def update_tempdir(*args):
            par.tempdir = tempdir.get()
            tempdir.set(par.tempdir)

        def update_threshold(*args):
            par.threshold = threshold.get()
            threshold.set(par.threshold)

        def update_threshold_type(*args):
#.........这里部分代码省略.........
开发者ID:kemichai,项目名称:EQcorrscan,代码行数:103,代码来源:parameter_setup.py

示例15: Xls2kml

# 需要导入模块: from tkinter import BooleanVar [as 别名]
# 或者: from tkinter.BooleanVar import set [as 别名]
class Xls2kml(object):
    '''
    Interface builted in Tkinter()
    '''

    def __init__(self):
        '''
        None -> None

        Builds the Tkinter window and all his elements.
        '''
        # variables ----------------------------------------------------
        # log file
        open("erros.log", "w").close()  # to open and clean the logfile
        logging.basicConfig(level=logging.DEBUG, filename='erros.log')
        sys.stderr = LogFile('stderr')  # Redirect stderr
        self.original_working_dir = os.getcwd()  # original working dir
        self.master = Tk()  # Tk() object
        self.master.title('EXCEL to KMZ Transformer - ver. 1.6')  # window name
        icons = os.getcwd() + os.sep + "icons" + os.sep  # path to icons
        foto_folder = os.getcwd() + os.sep + "fotos"  # path to fotos
        icon = icons + "compass.ico"
        self.master.iconbitmap(icon)  # window icon
        self.master.resizable(width=FALSE, height=FALSE)
        self.master.geometry("548x314")
        self.file_name = ""  # the name of the EXEL file
        self.last_dir = "C:/"
        # image to decorate the window
        self.img = ImageTk.PhotoImage(Image.open(icons + "excel-kmz.jpg"))
        # to use in frame, message, labels and buttons -----------------
        self.message = StringVar()
        self.message.set("\nSelecciona um ficheiro EXCEL")
        bg = "gray25"
        bg1 = "dark orange"
        fc = "white smoke"
        font = ("Helvetica", "8", "bold")
        text0 = " ----- "  # " ------------------------------------------ "
        text1 = " Boris & Vladimir Software "
        text = text0 + text1 + text0

        # Menu ---------------------------------------------------------
        self.menu = Menu(self.master)
        self.master.config(menu=self.menu)
        filemenu = Menu(self.menu)
        self.menu.add_cascade(label="Ficheiro", menu=filemenu)
        filemenu.add_command(label="Sair", command=self.__callback_3)
        filemenu.add_command(label='Pasta Fotos', command=lambda: (self.__open_folder(foto_folder)))
        # --------------------- NOVO -----------------------------------
        self.openGE = BooleanVar()  # não esquecer de importar BooleanVar
        self.openGE.set(False)
        optionsmenu = Menu(self.menu)
        self.menu.add_cascade(label="Opções", menu=optionsmenu)
        optionsmenu.add_checkbutton(label="Não abrir o Google Earth",
                                    onvalue=True, offvalue=False,
                                    variable=self.openGE)
        docsmenu = Menu(self.menu)
        docs = ["docs\manual.pdf", "docs\icons.pdf", "docs\colors.pdf",
                "docs\GPS.xlsx", "docs\GPS.kmz", "docs\Celulas.xlsx",
                "docs\Celulas.kmz", "docs\Foto.xlsx", "docs\Foto.kmz",
                "docs\Quadrado.xls", "docs\Quadrado.kmz"]
        self.menu.add_cascade(label="Documentação", menu=docsmenu)
        docsmenu.add_command(label="Manual",
                             command=lambda: (self.__open_file(docs[0])))
        docsmenu.add_command(label="Ícones",
                             command=lambda: (self.__open_file(docs[1])))
        docsmenu.add_command(label="Cores",
                             command=lambda: (self.__open_file(docs[2])))

        exemplemenu = Menu(docsmenu)
        docsmenu.add_cascade(label="Exemplos", menu=exemplemenu)

        gpsmenu = Menu(exemplemenu)
        exemplemenu.add_cascade(label="Trajetos", menu=gpsmenu)
        gpsmenu.add_command(label="Excel",
                            command=lambda: (self.__open_file(docs[3])))
        gpsmenu.add_command(label="Google Earth",
                            command=lambda: (self.__open_file(docs[4])))

        cellmenu = Menu(exemplemenu)
        exemplemenu.add_cascade(label="Células Telefónicas", menu=cellmenu)
        cellmenu.add_command(label="Excel",
                             command=lambda: (self.__open_file(docs[5])))
        cellmenu.add_command(label="Google Earth",
                             command=lambda: (self.__open_file(docs[6])))

        fotomenu = Menu(exemplemenu)
        exemplemenu.add_cascade(label="Fotos", menu=fotomenu)
        fotomenu.add_command(label="Excel",
                             command=lambda: (self.__open_file(docs[7])))
        fotomenu.add_command(label="Google Earth",
                             command=lambda: (self.__open_file(docs[8])))

        squaremenu = Menu(exemplemenu)
        exemplemenu.add_cascade(label="Quadrado", menu=squaremenu)
        squaremenu.add_command(label="Excel",
                             command=lambda: (self.__open_file(docs[9])))
        squaremenu.add_command(label="Google Earth",
                             command=lambda: (self.__open_file(docs[10])))

        helpmenu = Menu(self.menu)
#.........这里部分代码省略.........
开发者ID:lvsitanvs,项目名称:xls2kmz,代码行数:103,代码来源:xls2kml.py


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