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


Python DoubleVar.set方法代码示例

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


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

示例1: Gui

# 需要导入模块: from tkinter import DoubleVar [as 别名]
# 或者: from tkinter.DoubleVar import set [as 别名]
class Gui(Frame):
    def __init__(self, control, *args, **kwargs):
        Frame.__init__(self, *args, **kwargs)
        self.config(padx=2)
        self.queue = Queue()
        self.control = control
        self.disabledWhileRunning = []

        self.formulae = list(map(lambda t: StringVar(self, t), ["x/22.5+4", "50-x*50/180"]))
        self.executionTime = DoubleVar(self, "360")
        self.programSpeed = IntVar(self, "292")
        self.maxTravel = IntVar(self, "-200000")
        self.loadSettings()

        self.createWidgets()
        self.thread = None

    def compileFormulae(self):
        rv = []
        for f in self.formulae:
            body = "def formula5480750923(x):\n  return " + f.get()
            l = {}
            try:
                exec(body, {}, l)
            except:
                rv.append(None)
                continue
            compiled = l["formula5480750923"]
            compiled(0)
            rv.append(compiled)
        return rv

    def plotFormulae(self):
        try:
            compiled = self.compileFormulae()
        except:
            return
        for g in self.graphs:
            g.points = []
        self.canvas.x.end = self.executionTime.get()
        self.canvas.clear()
        for x in range(self.canvas.x.start, int(self.canvas.x.end)):
            point = []
            for c in range(len(compiled)):
                v = None
                if compiled[c]:
                    v = compiled[c](x)
                assert isinstance(v, float)
                point.append(v)
            self.__addPoint__(x, point)
        self.canvas.update()

    def __start__(self):
        self.canvas.x.end = self.executionTime.get()
        pumps = self.compileFormulae()
        self.setValues()
        self.control.mover.setSpeed(abs(int(self.programSpeed.get())))
        start_time = float(self.current_time.get())

        def calcPumpValues(time):
            values = list(map(lambda x: x(time), pumps))
            self.__addPoint__(time, values)
            self.current_time.set(time)
            return values

        def thFunc():
            try:
                for g in self.graphs:
                    g.points = []
                self.control.executeProgram(start_time, calcPumpValues)
            finally:
                self.invoke(self.__enableControls__)

        self.__disableControls__()
        self.canvas.clear()
        self.thread = Thread(target=thFunc, name="Control")
        self.thread.start()

    def __enableControls__(self):
        for e in self.disabledWhileRunning:
            e.config(state=NORMAL)

    def __disableControls__(self):
        for e in self.disabledWhileRunning:
            e.config(state="disabled")

    def __addPoint__(self, x, values):
        for v in values:
            assert isinstance(v, float)

        def c():
            for i in range(len(self.canvas.graphs)):
                self.canvas.graphs[i].addPoint(x, values[i])

        self.invoke(c)

    def invoke(self, callable):
        self.after_idle(callable)

    def __stop__(self):
#.........这里部分代码省略.........
开发者ID:basilevs,项目名称:varfill,代码行数:103,代码来源:gui.py

示例2: initui

# 需要导入模块: from tkinter import DoubleVar [as 别名]
# 或者: from tkinter.DoubleVar import set [as 别名]
    def initui(self):

        self.parent.title("Light pollution map")
        self.style = Style()
        self.style.theme_use("alt")

        self.grid(row=0, column=0)

        padding = {'padx':'5', 'pady':'5'}
        big_heading_font = ("Arial", 14, 'bold')
        small_heading_font = ("Arial", 10, 'bold')

        # Create frames.
        # There are three frames for settings - preprocessing, convolve, and contour.
        # Each also has an image frame underneath it.
        # Layout is as follows:
        #
        #             --------------------------------------------------------------------------
        #             |                 |                 |                 |                  |
        #             |                 |                 |                 |                  |
        #             |   import_body   |   process_body  |   contour_body  |   export_body    |
        #             |                 |                 |                 |                  |
        #             |                 |                 |                 |                  |
        #             --------------------------------------------------------------------------

        # Settings frames

        top = self.winfo_toplevel()
        top.rowconfigure(0, weight=1)
        top.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1)
        self.columnconfigure(1, weight=1)
        self.columnconfigure(2, weight=1)
        self.columnconfigure(3, weight=1)

        import_body = Frame(self, relief=RAISED, borderwidth=1)
        import_body.grid(row=0, column=0, sticky=N+S+E+W)

        process_body = Frame(self, relief=RAISED, borderwidth=1)
        process_body.grid(row=0, column=1, sticky=N+S+E+W)

        contour_body = Frame(self, relief=RAISED, borderwidth=1)
        contour_body.grid(row=0, column=2, sticky=N+S+E+W)

        export_body = Frame(self, relief=RAISED, borderwidth=1)
        export_body.grid(row=0, column=3, sticky=N+S+E+W)

         # =============================================================================================================
        #
        # Contents of load_image_frame
        #
        # =============================================================================================================

        # Heading

        processing_frame_header = Label(import_body, text="Import", font=big_heading_font)
        processing_frame_header.grid(row=0, column=0, sticky=N, **padding)

        filename_variable = StringVar()

        # Import image

        import_canvas = Canvas(import_body, width=canvas_size, height=canvas_size, background='black')
        import_canvas.grid(row=1, column=0, sticky=N, **padding)

        # Load file method

        def choosefile():
            filename_variable.set(filedialog.askopenfilename(parent=import_body))
            image = Image.open(filename_variable.get())
            thumbnail = create_thumbnail(image, canvas_size)
            import_canvas.create_image(0, 0, image=thumbnail, anchor=NW)

        load_image_button = Button(import_body, text="Import image", command=choosefile)
        load_image_button.grid(row=2, column=0, columnspan=2, sticky=E+W+S, **padding)
        import_body.rowconfigure(2, weight=1)

        # =============================================================================================================
        #
        # Contents of processing_frame
        #
        # =============================================================================================================

        processing_frame_header = Label(process_body, text="Process", font=big_heading_font)
        processing_frame_header.grid(row=0, column=0, columnspan=2, sticky=N, **padding)

        clipping_variable = IntVar()

        constants_label = Label(process_body, text="Clipping",
                                font=("Arial", 10, 'bold'))
        constants_label.grid(row=1, column=0, sticky=E, **padding)

        clipping_label = Label(process_body, text="Remove pixels with \n brightness under")
        clipping_label.grid(row=2, column=0, sticky=E, **padding)

        clipping_entry = Entry(process_body, textvariable=clipping_variable, width=4)
        clipping_entry.grid(row=2, column=1, sticky=W, **padding)

        clipping_variable.set(value=default_clipping_value)
#.........这里部分代码省略.........
开发者ID:arran-dengate,项目名称:light-pollution,代码行数:103,代码来源:controller.py

示例3: __init__

# 需要导入模块: from tkinter import DoubleVar [as 别名]
# 或者: from tkinter.DoubleVar 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

示例4: __init__

# 需要导入模块: from tkinter import DoubleVar [as 别名]
# 或者: from tkinter.DoubleVar import set [as 别名]
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        
        Home_Button = ttk.Button(self, text = "Home", command = lambda: controller.show_frame(home_module.Home)) # Button to open Home screen
        Home_Button.grid(column = 2, row = 9, sticky = "nwes")
        
        WDB_Button = ttk.Button(self, text = "Watts To dB", command = lambda: controller.show_frame(watts_to_decibels.WDB))# Button to open W to dB screen
        WDB_Button.grid(column = 1, row = 9, sticky = "nwes")
            
        def dB_W(*args):
            try:
                Value = float(Data_In.get())
                Range_Set = str(Range_1.get())
                if Range_Set == 'dBm':
                    dBm.set(Value)
                    dBW.set(Value - 30)
                    dBk.set(Value - 60)
                    mW.set(pow(10, (Value / 10)))
                    W.set(pow(10, (Value / 10)) / 1000)
                    kW.set(pow(10, (Value / 10)) / 1000000)
                if Range_Set == 'dBW':
                    dBm.set(Value + 30)
                    dBW.set(Value)
                    dBk.set(Value - 30)
                    mW.set(pow(10, (Value / 10)) * 1000)
                    W.set(pow(10, (Value / 10)))
                    kW.set(pow(10, (Value / 10)) / 1000)
                if Range_Set == 'dBk':
                    dBm.set(Value + 60)
                    dBW.set(Value + 30)
                    dBk.set(Value)
                    mW.set(pow(10, (Value / 10)) * 1000000)
                    W.set(pow(10, (Value / 10)) * 1000)
                    kW.set(pow(10, (Value / 10)))
                      
            except ValueError:
                dBm.set(0.0)
                dBW.set(0.0)
                dBk.set(0.0)
                mW.set(0.0)
                W.set(0.0)
                kW.set(0.0)   
                
        def dB_range_select(*args):
            Range_Set = str(Range_1.get())
            if Range_Set == 'dBm':
                Range_2.set("mW")
            if Range_Set == 'dBW':
                Range_2.set("W")
            if Range_Set == 'dBk':
                Range_2.set("kW")
    
        Range_1 = StringVar()
        Range_1.set('dBm')
        Range_2 = StringVar()
        Range_2.set('mW')
        Range_Selection = ttk.Combobox(self, textvariable = Range_1, state = 'readonly')
        Range_Selection['values'] = ('dBm', 'dBW', 'dBk')
        Range_Selection.grid(column = 2, row = 1, sticky = "nwes")
        Range_Selection.bind('<<ComboboxSelected>>', dB_range_select)
        
        Data_In = StringVar()
        Data_In.set(0)
        dBm = StringVar()
        dBm.set(0.0)
        dBW = StringVar()
        dBW.set(0.0)
        dBk = StringVar()
        dBk.set(0.0)
        mW = StringVar()
        mW.set(0.0)
        W = StringVar()
        W.set(0.0)
        kW = DoubleVar()
        kW.set(0.0)

        dB_entry = ttk.Entry(self, width = 7, textvariable = Data_In)
        dB_entry.grid(column = 2, row = 2, sticky = "nwes")
        
        ttk.Label(self, textvariable = dBm).grid(column = 2, row = 3, sticky = "nwes")
        ttk.Label(self, textvariable = dBW).grid(column = 2, row = 4, sticky = "nwes")
        ttk.Label(self, textvariable = dBk).grid(column = 2, row = 5, sticky = "nwes")
        ttk.Label(self, textvariable = mW).grid(column = 2, row = 6, sticky = "nwes")
        ttk.Label(self, textvariable = W).grid(column = 2, row = 7, sticky = "nwes")
        ttk.Label(self, textvariable = kW).grid(column = 2, row = 8, sticky = "nwes")
    
        ttk.Button(self, text = "Calculate", command = dB_W).grid(column = 3, row = 9, sticky = "nwes")
        
        ttk.Label(self, text = "Please choose a range :").grid(column = 1, row = 1, sticky = "nwes")
        ttk.Label(self, text = "Please enter a number :").grid(column = 1, row = 2, sticky = "nwes")
        ttk.Label(self, textvariable = Range_1).grid(column = 3, row = 2, sticky = "nwes")
        ttk.Label(self, text = "Is equivalent to :").grid(column = 1, row = 3, sticky = "nwes")
        ttk.Label(self, textvariable = Range_2).grid(column = 3, row = 3, sticky = "nwes")
        
        ttk.Label(self, text = "dBm").grid(column = 3, row = 3, sticky = "nwes")
        ttk.Label(self, text = "dBW").grid(column = 3, row = 4, sticky = "nwes")
        ttk.Label(self, text = "dBk").grid(column = 3, row = 5, sticky = "nwes")
        ttk.Label(self, text = "mW").grid(column = 3, row = 6, sticky = "nwes")
        ttk.Label(self, text = "W").grid(column = 3, row = 7, sticky = "nwes")
        ttk.Label(self, text = "kW").grid(column = 3, row = 8, sticky = "nwes")
#.........这里部分代码省略.........
开发者ID:GothiKal,项目名称:Calculator-Converter,代码行数:103,代码来源:decibels_to_watts.py


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