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


Python tkinter.DoubleVar方法代码示例

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


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

示例1: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def __init__(self, master, gui):
        super().__init__(master, text="output: Tremolo")
        self.gui = gui
        self.input_waveform = tk.StringVar()
        self.input_waveform.set("<off>")
        self.input_rate = tk.DoubleVar()
        self.input_depth = tk.DoubleVar()
        self.input_rate.set(5)
        self.input_depth.set(80)
        row = 0
        tk.Label(self, text="waveform").grid(row=row, column=0)
        values = ["<off>", "sine", "triangle", "sawtooth", "square"]
        menu = tk.OptionMenu(self, self.input_waveform, *values)
        menu["width"] = 10
        menu.grid(row=row, column=1)
        row += 1
        tk.Label(self, text="rate").grid(row=row, column=0, sticky=tk.E)
        tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_rate, from_=0.0, to=10.0, resolution=.1,
                 width=10, length=100).grid(row=row, column=1)
        row += 1
        tk.Label(self, text="depth").grid(row=row, column=0, sticky=tk.E)
        tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_depth, from_=0.0, to=1.0, resolution=.02,
                 width=10, length=100).grid(row=row, column=1) 
开发者ID:irmen,项目名称:synthesizer,代码行数:25,代码来源:keyboard_gui.py

示例2: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def __init__(self, *args, min_var=None, max_var=None,
                 focus_update_var=None, from_='-Infinity', to='Infinity',
                 **kwargs):
        super().__init__(*args, from_=from_, to=to, **kwargs)
        self.resolution = Decimal(str(kwargs.get('increment', '1.0')))
        self.precision = self.resolution.normalize().as_tuple().exponent
        # there should always be a variable,
        # or some of our code will fail
        self.variable = kwargs.get('textvariable') or tk.DoubleVar()

        if min_var:
            self.min_var = min_var
            self.min_var.trace('w', self._set_minimum)
        if max_var:
            self.max_var = max_var
            self.max_var.trace('w', self._set_maximum)
        self.focus_update_var = focus_update_var
        self.bind('<FocusOut>', self._set_focus_update_var) 
开发者ID:PacktPublishing,项目名称:Python-GUI-Programming-with-Tkinter,代码行数:20,代码来源:widgets.py

示例3: load_settings

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def load_settings(self):
        """Load settings into our self.settings dict."""

        vartypes = {
            'bool': tk.BooleanVar,
            'str': tk.StringVar,
            'int': tk.IntVar,
            'float': tk.DoubleVar
        }

        # create our dict of settings variables from the model's settings.
        self.settings = {}
        for key, data in self.settings_model.variables.items():
            vartype = vartypes.get(data['type'], tk.StringVar)
            self.settings[key] = vartype(value=data['value'])

        # put a trace on the variables so they get stored when changed.
        for var in self.settings.values():
            var.trace('w', self.save_settings) 
开发者ID:PacktPublishing,项目名称:Python-GUI-Programming-with-Tkinter,代码行数:21,代码来源:application.py

示例4: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def __init__(self, STATE):

        self.STATE = STATE

        self.STATE.trw_completed = StringVar(self.STATE.mainGUI)
        self.STATE.trw_completed.set("Not run")

        self.STATE.rotation_voltage = DoubleVar(self.STATE.mainGUI)
        self.STATE.rotation_voltage.set(2)

        self.STATE.angular_mode = BooleanVar(self.STATE.mainGUI)
        self.STATE.angular_mode.set(False)

        self.stored_data = {}

        self.queue = queue.Queue()
        self.mode = "disabled"
        self.data = []
        self.lock = threading.Condition()

        # Tells the listener to not store data
        self.discard_data = True

        # Last telemetry data received from the robot
        self.last_data = (0,) * 20 
开发者ID:wpilibsuite,项目名称:frc-characterization,代码行数:27,代码来源:data_logger.py

示例5: get

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def get(self):
        """ Return the value from the tk_var

        Notes
        -----
        tk variables don't like empty values if it's not a stringVar. This seems to be pretty
        much the only reason that a get() call would fail, so replace any numerical variable
        with it's numerical zero equivalent on a TCL Error. Only impacts variables linked
        to Entry widgets.
        """
        try:
            val = self.tk_var.get()
        except TclError:
            if isinstance(self.tk_var, tk.IntVar):
                val = 0
            elif isinstance(self.tk_var, tk.DoubleVar):
                val = 0.0
            else:
                raise
        return val 
开发者ID:deepfakes,项目名称:faceswap,代码行数:22,代码来源:control_helper.py

示例6: get_tk_var

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def get_tk_var(self, track_modified):
        """ Correct variable type for control """
        if self.dtype == bool:
            var = tk.BooleanVar()
        elif self.dtype == int:
            var = tk.IntVar()
        elif self.dtype == float:
            var = tk.DoubleVar()
        else:
            var = tk.StringVar()
        logger.debug("Setting tk variable: (name: '%s', dtype: %s, tk_var: %s)",
                     self.name, self.dtype, var)
        if track_modified and self._command is not None:
            logger.debug("Tracking variable modification: %s", self.name)
            var.trace("w",
                      lambda name, index, mode, cmd=self._command: self._modified_callback(cmd))

        if track_modified and self._command in ("train", "convert") and self.title == "Model Dir":
            var.trace("w", lambda name, index, mode, v=var: self._model_callback(v))

        return var 
开发者ID:deepfakes,项目名称:faceswap,代码行数:23,代码来源:control_helper.py

示例7: set_vars

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def set_vars():
        """ Analysis specific vars """
        enabled = tk.BooleanVar()
        enabled.set(True)

        ready = tk.BooleanVar()
        ready.set(False)

        modified = tk.DoubleVar()
        modified.set(None)

        tk_vars = {"enabled": enabled,
                   "ready": ready,
                   "modified": modified}
        logger.debug(tk_vars)
        return tk_vars

    # INFO LABEL 
开发者ID:deepfakes,项目名称:faceswap,代码行数:20,代码来源:display_page.py

示例8: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def __init__(self, master):
        
        # More advanced as compared to regular buttons 
        # Check buttons can also store binary values
        self.checkbutton = ttk.Checkbutton(master, text = 'Check Me!')
        self.checkbutton.pack()
        self.label = ttk.Label(master, text = 'Ready!! Nothing has happened yet.')
        self.label.pack()
        # Tkinter variable classes
        # self.boolvar = tk.BooleanVar()   # boolean type variable of tk
        # self.dblvar = tk.DoubleVar()     # double type variable of tk
        # self.intvar = tk.IntVar()        # int type variable of tk
        self.checkme = tk.StringVar()     # string type variable of tk
        self.checkme.set('NULL')            # set value for string type tkinter variable
        print('Current value of checkme variable is \'{}\''.format(self.checkme.get()))
        
        # setting of binary value for check button: 1. onvaalue and 2. offvalue
        self.checkbutton.config(variable = self.checkme, onvalue = 'I am checked!!', offvalue = 'Waiting for someone to check me!')
        self.checkbutton.config(command = self.oncheckme)
        
        
        # creating another tkinter string type variable - StringVar
        self.papertype = tk.StringVar()     # created a variable
        self.radiobutton1 = ttk.Radiobutton(master, text = 'Paper1', variable=self.papertype, value = 'Robotics Research')
        self.radiobutton1.config(command = self.onselectradio)
        self.radiobutton1.pack()
        self.radiobutton2 = ttk.Radiobutton(master, text = 'Paper2', variable=self.papertype, value = 'Solid Mechanics Research')
        self.radiobutton2.config(command = self.onselectradio)
        self.radiobutton2.pack()
        self.radiobutton3 = ttk.Radiobutton(master, text = 'Paper3', variable=self.papertype, value = 'Biology Research')
        self.radiobutton3.config(command = self.onselectradio)
        self.radiobutton3.pack()
        self.radiobutton4 = ttk.Radiobutton(master, text = 'Paper4', variable=self.papertype, value = 'SPAM Research')
        self.radiobutton4.config(command = self.onselectradio)
        self.radiobutton4.pack()
        self.radiobutton5 = ttk.Radiobutton(master, text = 'Change Checkme text', variable=self.papertype, value = 'Radio Checkme Selected')
        self.radiobutton5.pack()
        self.radiobutton5.config(command = self.onradiobuttonselect) 
开发者ID:adipandas,项目名称:python-gui-demos,代码行数:40,代码来源:program5.py

示例9: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def __init__(self, master):
        ttk.Label(master, text = "PROGRESS CONTROL").pack()
        
        # Inderterminant Progressbar
        ttk.Label(master, text = 'Inderterminant Progress').pack()
        self.prgrsbr_indtr = ttk.Progressbar(master, orient = tk.HORIZONTAL, length = 300, mode = 'indeterminate')
        self.prgrsbr_indtr.pack()
        self.checkpbi = tk.StringVar()
        self.checkpbi.set("Start")
        
        # Button
        self.btn1 = ttk.Button(master, text = "{} Inderterminant Progress Bar".format(self.checkpbi.get()), command = self.btn1cmd)
        self.btn1.pack()

        # Derterminant progress
        ttk.Label(master, text = 'Derterminant Progress').pack()
        self.prgrsbr_dtr = ttk.Progressbar(master, orient=tk.HORIZONTAL, length = 300, mode = 'determinate')
        self.prgrsbr_dtr.pack()
        self.prgrsbr_dtr.config(maximum = 10.0, value = 2.0)    # notice both these properties have float values
        
        # Button
        ttk.Button(master, text = 'Reset Progress Bar to zero', command = self.resetProgressBarVal).pack()
        
        # Button
        ttk.Button(master, text = 'Increase Progress Bar by 2', command = self.shift2ProgressBarVal).pack()
        
        # create double variable
        self.prgrsBrVal = tk.DoubleVar()
        
        self.prgrsbr_dtr.config(variable = self.prgrsBrVal) # set variable property of progressbar to look at DoubleVar()
        
        # Scale widget
        self.scalebar = ttk.Scale(master, orient = tk.HORIZONTAL, length = 400, variable=self.prgrsBrVal, from_ = 0.0, to= 10.0)
        self.scalebar.pack()
        
        # Label to display current value of scalebar
        ttk.Label(master, text = "Current value of Progress Bar is as below:").pack()
        self.scalebar_label = ttk.Label(master, textvariable = self.prgrsBrVal)
        self.scalebar_label.pack() 
开发者ID:adipandas,项目名称:python-gui-demos,代码行数:41,代码来源:program8.py

示例10: start_progress_bar

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def start_progress_bar(self, path):
        '''Pop up a progress bar starting at 0% while the wordlist is processing
        '''
        self.progress_path = path
        
        self.progress_popup = Tk.Toplevel()
        self.progress_popup.title('Processing')
        self.progress_popup.resizable(width=False, height=False)
        self.progress_popup.grab_set()
        self.progress_popup.overrideredirect(1)
        
        progress_frame = Tk.Frame(self.progress_popup, borderwidth=1, relief=Tk.RAISED)
        progress_frame.pack(side='top', fill='both', padx=10, pady=10)
        
        path_label = Tk.Label(progress_frame, text='', font=('Helvetica', '12'))
        path_label.pack(padx=10, pady=10)
        path_label.configure(text="Processing to '{}'...".format(path))
        
        self.progress_var = Tk.DoubleVar()
        self.progress_bar = ttk.Progressbar(progress_frame, variable=self.progress_var,
            length=300, maximum=100, style='plain.Horizontal.TProgressbar')
        self.progress_bar.pack(side='left', padx=10, pady=10)
        
        self.progress_percent_lb = Tk.Label(progress_frame, text='', font=('Helvetica', '12'))
        self.progress_percent_lb.pack(side='left', padx=10, pady=10)
        self.progress_percent_lb.configure(text='0%')
        
        def stop(): self.controller.stop_processing_flag = True
        self.progress_btn = Tk.Button(progress_frame, text='Cancel', command=stop)
        self.progress_btn.pack(side='left', padx=10, pady=20)
        
        center_window(self.progress_popup, self.master)
        self.progress_popup.update() 
开发者ID:sc0tfree,项目名称:mentalist,代码行数:35,代码来源:main.py

示例11: add_entry

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def add_entry(self, **kwargs):
    """
    To add an entry box. The adding of the entry box will add an attribute,
    if no variable is specified.

    args:
    - vartype: to specify which type the variable associated with the entry
    will be. Useful to make sure the user does not enter a string when a
    number is expected.
    - variable: the variables name, which will be set as an attribute.
    - width : the width of the entry box.
    """
    widgets_dict = kwargs.pop('widgets_dict', None)
    frame = kwargs.pop('frame', None)
    entry_name = kwargs.pop('name', 'name')
    width = kwargs.pop('width', 10)
    vartype = kwargs.pop('vartype', tk.DoubleVar())
    variable = kwargs.pop("variable", None)

    if not variable:
      setattr(self, entry_name + '_var', vartype)
      widgets_dict[entry_name] = tk.Entry(frame,
                                        textvariable=getattr(self, entry_name+
                                        '_var'),
                                          width=width)
    else:
      widgets_dict[entry_name] = tk.Entry(frame,
                                          textvariable=variable,
                                          width=width) 
开发者ID:LaboratoireMecaniqueLille,项目名称:crappy,代码行数:31,代码来源:frame_objects.py

示例12: setUp

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def setUp(self):
        self.value = tk.DoubleVar()
        self.vsb = widgets.ValidatedSpinbox(
            self.root,
            textvariable=self.value,
            from_=-10, to=10, increment=1
        )
        self.vsb.pack()
        self.vsb.wait_visibility() 
开发者ID:PacktPublishing,项目名称:Python-GUI-Programming-with-Tkinter,代码行数:11,代码来源:test_widgets.py


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