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


Python DoubleVar.trace方法代码示例

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


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

示例1: Gui

# 需要导入模块: from tkinter import DoubleVar [as 别名]
# 或者: from tkinter.DoubleVar import trace [as 别名]

#.........这里部分代码省略.........
        config.configureControl(self.control)
        for i in range(len(self.formulae)):
            self.formulae[i].set(config.formulae[i])
        self.showValues()

    def saveSettings(self):
        self.setValues()
        config = Config()
        config.getFromControl(self.control)
        for i in range(len(self.formulae)):
            config.formulae[i] = self.formulae[i].get()
        config.write()

    def createWidgets(self):
        panel = Frame(self, name="mainMenu")
        panel.grid(sticky=W)
        Button(panel, name="quit", text="Выход", command=self.__quit__).grid(row=0, column=0)
        Button(panel, name="reconnect", text="Пересоединение", command=self.control.reconnect).grid(row=0, column=1)
        b = Button(panel, text="Загрузить", command=self.loadSettings)
        b.grid(row=0, column=2)
        self.disabledWhileRunning.append(b)
        b = Button(panel, text="Сохранить", command=self.saveSettings)
        b.grid(row=0, column=3)
        self.disabledWhileRunning.append(b)
        panel = LabelFrame(self, text="Прямое управление стаканом", name="motor")
        panel.grid(sticky=W)
        b = Button(panel, text="Вверх", command=self.__up__, name="up")
        b.grid(row=0, column=0)
        self.disabledWhileRunning.append(b)
        b = Button(panel, text="Вниз", command=self.__down__, name="down")
        b.grid(row=1, column=0)
        self.disabledWhileRunning.append(b)
        Label(panel, text="Шаг:").grid(sticky=E, row=0, column=1)
        self.steps = IntVar(self, "10000")
        Entry(panel, textvariable=self.steps, width=6).grid(sticky=W, row=0, column=2)
        Label(panel, text="Скорость:").grid(sticky=E, row=1, column=1)
        self.speed = IntVar(self, "2000")
        Entry(panel, textvariable=self.speed, width=6).grid(sticky=W, row=1, column=2)
        self.position = IntVar(self, "1000")

        def readPosition():
            try:
                self.position.set(self.control.mover.getPosition())
            except (ConnectionResetError, Timeout):
                pass

        run_repeating(self, readPosition, 10000)
        b = Button(panel, text="Прочитать положение", command=readPosition)
        b.grid(row=0, column=3, columnspan=2)
        self.disabledWhileRunning.append(b)
        Label(panel, text="Положение:").grid(sticky=E, row=1, column=3)
        Entry(panel, textvariable=self.position, width=8, state="disabled").grid(sticky=W, row=1, column=4)

        panel = LabelFrame(self, text="Программа", name="program")
        program = panel
        panel.grid(sticky=W + E)
        panel.columnconfigure(1, weight=1)
        row = 0
        for f in self.formulae:
            columns, rows = self.grid_size()
            Label(panel, text="Насос %d:" % (row + 1)).grid(row=row, column=0, sticky=E)
            e = Entry(panel, textvariable=f)
            e.grid(sticky=E + W, row=row, column=1)
            self.disabledWhileRunning.append(e)
            f.trace("w", lambda *x: self.after_idle(self.plotFormulae))
            row += 1
        panel = Frame(program, name="mover")
        panel.grid(columnspan=2, sticky=W)
        Label(panel, text="Максимальное смещение:").grid(sticky=E)
        Entry(panel, textvariable=self.maxTravel).grid(sticky=W, row=0, column=1)
        Label(panel, text="Скорость:").grid(sticky=E)
        Entry(panel, textvariable=self.programSpeed).grid(sticky=W, row=1, column=1)
        Label(panel, text="Время выполнения (в секундах):").grid(sticky=E)
        e = Entry(panel, textvariable=self.executionTime)
        e.grid(sticky=W, row=2, column=1)
        self.current_time = DoubleVar(self, "0")
        Label(panel, text="Текущее время:").grid(sticky=E)
        e = Entry(panel, textvariable=self.current_time)
        e.grid(sticky=W, row=3, column=1)
        self.disabledWhileRunning.append(e)
        self.executionTime.trace("w", lambda *x: self.plotFormulae())

        panel = Frame(program, name="bottom")
        panel.grid(columnspan=2, sticky=W)
        row = 0
        startButton = Button(panel, name="start", text="Старт", command=self.__start__)
        startButton.grid(row=row, column=0)
        self.disabledWhileRunning.append(startButton)
        Button(panel, text="Стоп", command=self.__stop__).grid(row=row, column=1)

        self.canvas = GraphCanvas(self)
        self.graphs = (Graph(self.canvas), Graph(self.canvas))

        self.canvas.x.end = 100
        self.canvas.y.end = 24
        self.plotFormulae()
        self.canvas.grid(sticky=E + W + S + N)
        columns, rows = self.grid_size()
        self.columnconfigure(columns - 1, weight=1)
        self.rowconfigure(rows - 1, weight=1)
开发者ID:basilevs,项目名称:varfill,代码行数:104,代码来源:gui.py

示例2: __init__

# 需要导入模块: from tkinter import DoubleVar [as 别名]
# 或者: from tkinter.DoubleVar import trace [as 别名]

#.........这里部分代码省略.........
            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):
            par.threshold_type = threshold_type.get()
            threshold_type.set(par.threshold_type)

        def update_plotdir(*args):
            par.plotdir = plotdir.get()
            plotdir.set(par.plotdir)

        def update_trigger_interval(*args):
            par.trigger_interval = trigger_interval.get()
            trigger_interval.set(par.trigger_interval)
        # Set some grid parameters
        nrows = 25
        ncolumns = 3
        self.master = master
        master.title("EQcorrscan parameter setup")
        self.label = Label(master, text="Alpha GUI for default setup")
        self.label.grid(column=0, columnspan=ncolumns, row=0)

        # Set up parameter input
        self.t_names_label = Label(master, text="Template names", anchor='e')
        self.t_names_label.grid(column=0, row=1, sticky='e')
        template_names = StringVar()
        template_names.set(', '.join(par.template_names))
        self.t_names_box = Entry(master, bd=2, textvariable=template_names)
        self.t_names_box.grid(column=1, row=1)
        template_names.trace("w", update_template_names)
        self.t_names_lookup = Button(master, text="Lookup",
                                     command=lambda: self.get_template_names(par))
        self.t_names_lookup.grid(column=2, row=1)

        self.lowcut_label = Label(master, text="Lowcut (Hz)", anchor='e')
        self.lowcut_label.grid(column=0, row=2, sticky='e')
        lowcut = DoubleVar()
        lowcut.set(par.lowcut)
        self.lowcut_box = Entry(master, bd=2, textvariable=lowcut)
        self.lowcut_box.grid(column=1, row=2)
        lowcut.trace("w", update_lowcut)

        self.highcut_label = Label(master, text="Highcut (Hz)", anchor='e')
        self.highcut_label.grid(column=0, row=3, sticky='e')
        highcut = DoubleVar()
        highcut.set(par.highcut)
        self.highcut_box = Entry(master, bd=2, textvariable=highcut)
        self.highcut_box.grid(column=1, row=3)
        highcut.trace("w", update_highcut)

        self.filt_order_label = Label(master, text="Filter order")
        self.filt_order_label.grid(column=0, row=4, sticky='e')
        filt_order = DoubleVar()
        filt_order.set(par.filt_order)
        self.filt_order_box = Entry(master, bd=2, textvariable=filt_order)
        self.filt_order_box.grid(column=1, row=4)
        filt_order.trace("w", update_filt_order)

        self.samp_rate_label = Label(master, text="Sample rate (Hz)")
        self.samp_rate_label.grid(column=0, row=5, sticky='e')
        samp_rate = DoubleVar()
        samp_rate.set(par.samp_rate)
开发者ID:kemichai,项目名称:EQcorrscan,代码行数:70,代码来源:parameter_setup.py


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