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


Python DoubleVar.get方法代码示例

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


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

示例1: test_get_from_int

# 需要导入模块: from tkinter import DoubleVar [as 别名]
# 或者: from tkinter.DoubleVar import get [as 别名]
 def test_get_from_int(self):
     v = DoubleVar(self.root, 1.23, "name")
     self.assertAlmostEqual(1.23, v.get())
     self.root.globalsetvar("name", "3.45")
     self.assertAlmostEqual(3.45, v.get())
     self.root.globalsetvar("name", "456")
     self.assertAlmostEqual(456, v.get())
开发者ID:Cartmanfku,项目名称:cpython,代码行数:9,代码来源:test_variables.py

示例2: test_invalid_value

# 需要导入模块: from tkinter import DoubleVar [as 别名]
# 或者: from tkinter.DoubleVar import get [as 别名]
 def test_invalid_value(self):
     v = DoubleVar(self.root, name="name")
     self.root.globalsetvar("name", "value")
     with self.assertRaises(ValueError):
         v.get()
开发者ID:Cartmanfku,项目名称:cpython,代码行数:7,代码来源:test_variables.py

示例3: test_default

# 需要导入模块: from tkinter import DoubleVar [as 别名]
# 或者: from tkinter.DoubleVar import get [as 别名]
 def test_default(self):
     v = DoubleVar(self.root)
     self.assertEqual(0.0, v.get())
开发者ID:Cartmanfku,项目名称:cpython,代码行数:5,代码来源:test_variables.py

示例4: TkMainGui

# 需要导入模块: from tkinter import DoubleVar [as 别名]
# 或者: from tkinter.DoubleVar import get [as 别名]
class TkMainGui(ttk.Frame):
    def __init__(self, root, default_folder=""):
        ttk.Frame.__init__(self, root, padding="3 3 12 12")
        self.default_folder = default_folder

        logging.debug("Create main frame")
        #mainframe = ttk.Frame(root, padding="3 3 12 12")
        self.grid(column=0, row=0, sticky=(N, W, E, S))
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)

        logging.debug("Create variable")
        self.filepath_ctf = StringVar()
        self.image_folder = StringVar()
        self.vh_ratio = DoubleVar(value=0.76200)
        self.results_text = StringVar()

        self.pcx = 0.0
        self.pcy = 0.0
        self.dd = 0.0

        logging.debug("Create ctf components")
        ctf_entry = ttk.Entry(self, width=80, textvariable=self.filepath_ctf)
        ctf_entry.grid(column=2, row=1, sticky=(W, E))
        ttk.Button(self, text="Select CTF file", command=self.open_ctf_file).grid(column=3, row=1, sticky=W)

        logging.debug("Create image folder components")
        image_entry = ttk.Entry(self, width=80, textvariable=self.image_folder)
        image_entry.grid(column=2, row=2, sticky=(W, E))
        ttk.Button(self, text="Select Image folder", command=self.open_image_folder).grid(column=3, row=2, sticky=W)

        logging.debug("Create vh_ratio components")
        ttk.Label(self, text="VH Ratio").grid(column=1, row=3, sticky=(W, E))
        image_entry = ttk.Entry(self, width=10, textvariable=self.vh_ratio)
        image_entry.grid(column=2, row=3, sticky=(W, E))

        ttk.Button(self, text="Prepare data", command=self.prepare_data, width=80).grid(column=2, row=4, sticky=W)

        results_label = ttk.Label(self, textvariable=self.results_text, state="readonly")
        results_label.grid(column=2, row=5, sticky=(W, E))

        for child in self.winfo_children():
            child.grid_configure(padx=5, pady=5)

        ctf_entry.focus()

    def open_ctf_file(self):
        logging.debug("open_ctf_file")

        filename = filedialog.askopenfilename(filetypes=(("CTF file", "*.ctf"), ), initialdir=self.default_folder)
        logging.debug(filename)
        self.filepath_ctf.set(filename)

        basename = os.path.splitext(filename)[0]
        if os.path.isdir(basename + "Images"):
            self.image_folder.set(basename + "Images")
        elif os.path.isdir(basename + "_Images"):
            self.image_folder.set(basename + "_Images")

    def open_image_folder(self):
        logging.debug("open_image_folder")

        folder_name = filedialog.askdirectory(initialdir=self.default_folder)
        logging.debug(folder_name)
        self.image_folder.set(folder_name)

    def prepare_data(self):
        logging.debug("prepare_data")

        self.find_pattern_parameters()
        self.create_cpr_file()
        self.rename_image_folder()

        if self.pcx == 0.0 or self.pcy == 0.0 or self.dd == 0.0 or self.vh_ratio == 0.0:
            self.results_text.set("Error")
        else:
            self.results_text.set("Completed")

    def find_pattern_parameters(self):
        logging.debug("find_pattern_parameters")

        number_files = 0
        extension = ""
        folder_name = self.image_folder.get()
        for filename in sorted(os.listdir(folder_name), reverse=True):
            try:
                basename, extension = os.path.splitext(filename)
                items = basename.split("_")
                number_files = int(items[-1])
                break
            except:
                pass
        logging.debug(number_files)
        logging.debug(filename)
        start = filename.rfind("_%i" % (number_files))
        image_filename = filename[:start+1] + "%0*i" % (len(str(number_files)), number_files/2) + extension
        logging.debug(image_filename)
        image_filepath = os.path.join(folder_name, image_filename)
        image = Image.open(image_filepath)
        for items in image.tag.values():
#.........这里部分代码省略.........
开发者ID:drix00,项目名称:pycrosscourt,代码行数:103,代码来源:main_gui.py

示例5: Gui

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

示例6: Nim

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

#.........这里部分代码省略.........
            self.lracunalnik.destroy()
            if igralec == 0:
                self.konec = Label(text='Čestitamo, zmagali ste!', bg = 'white', font=("Calibri", 24))
            else:
                self.konec = Label(text = 'Več sreče prihodnjič!', bg = 'white', font=("Calibri",24))
            self.konec.place(x=150, y=250)
            self.k1.destroy()
            self.k2.destroy()
            self.k3.destroy()

    def sestevek(self):
        s = 0
        for i in range(len(self.vrhovi)):
            s = s^self.vrhovi[i]
        return s
    def sestevki(self):
        return [a^self.X < a for a in self.vrhovi]
    def naredi_potezo_AI(self):
        #Ta del kode sem dobil tako, da sem priredil kodo iz wikipedije
        #vir: http://en.wikipedia.org/wiki/Nim
        self.X = self.sestevek()
        S = self.sestevki()
        odstranjenih = 0
        if self.X == 0:
            if max(self.vrhovi) >1:
                print("Can't win")
            for i, vrh in enumerate(self.vrhovi):
                if vrh>0:
                    izbrani, odstranjenih = i, vrh
        else:
            izbrani = S.index(True)
            odstranjenih = self.vrhovi[izbrani] - (self.vrhovi[izbrani]^self.X)
            dva_alivec = 0
            for i, vrh in enumerate(self.vrhovi):
                if i == izbrani:
                    if vrh-odstranjenih > 1:
                        dva_alivec += 1
                else:
                    if vrh > 1:
                        dva_alivec += 1
            if dva_alivec == 0:
                izbrani = self.vrhovi.index(max(self.vrhovi))
                vrhov_z1 = sum(v == 1 for v in self.vrhovi)
                if vrhov_z1%2 == 1:
                    odstranjenih = self.vrhovi[izbrani]-1
                else:
                    odstranjenih = self.vrhovi[izbrani]
                    
        if odstranjenih == 0:
            odstranjenih = 1
            izbrani  = self.vrhovi.index(True)
        x = 10*(1-(1/self.zahtevnost.get()))
        v = randint(1, 10)
        if v < x:
            neprazni = []
            for i, vr in enumerate(self.vrhovi):
                if vr>0:
                    neprazni.append(i)
            izbrani = choice(neprazni)
            odstranjenih = randint(1, self.vrhovi[izbrani])
        self.vrhovi[izbrani] -= odstranjenih
        self.unici_kamne()
        self.narisi_kamne(b=1)
        self.lracunalnik.place_forget()
        self.ligralec.place(x=300, y=130)
        self.preveri_zmagovalca(1)
#        print("Odstranil sem " + str(odstranjenih+1) + " kamenčkov iz " + str(izbrani+1) + " vrha.")
    def narisi_kamne(self, b=0):
#        print("narisi kamne")
        self.kamni = [[],[],[]]
        for i, j in enumerate(self.vrhovi):
            for k in range(j):
                self.kamni[i].append(Label(self, image=self.kamen, bd=0))
                self.kamni[i][k].place(x=(100+110*k), y=(200+110*i))
                par = (k+1, i+1)
                if b == 1:
                    self.kamni[i][k].bind('<Button-1>', partial(self.izberi_kamen, par))
                
    def unici_kamne(self):
        for vrh in self.kamni:
            for kamen in vrh:
                kamen.destroy()
            
    def naredi_potezo_clovek_text(self):
        izbrani =   int(input("Izberi vrh: "))
        odstranjenih = int(input("Stevilo kamenckov: "))
        self.vrhovi[izbrani] -= odstranjenih
#        print(self.vrhovi)
    
    def izberi_kamen(self, par, j):
#        print("izbrali ste kamen ", par[0], " iz ", par[1], " vrha.")
        self.vrhovi[par[1]-1] = par[0]-1
#        print(self.vrhovi)
        self.unici_kamne()
        self.narisi_kamne(0)
        self.ligralec.place_forget()
        self.lracunalnik.place(x=300, y=130)
        self.preveri_zmagovalca(0)
        
        self.after(1000, self.naredi_potezo_AI)
开发者ID:Januar1,项目名称:nim_game,代码行数:104,代码来源:nim.py

示例7: __init__

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

#.........这里部分代码省略.........
        Label(self.toplevel, text='[MHz]').grid(row=row, column=4, sticky='w')
        row += 1

        #ch_options = ['xdata', 'ydata']
        #OptionMenu(self.toplevel, self.fit_channel_Var, *ch_options
        #           ).grid(row=row, column=0, rowspan=2, sticky='ew')
        Button(self.toplevel, text='find resonance', command=self._FindResonance
               ).grid(row=row, column=1, rowspan=2, sticky='ew')
        Label(self.toplevel, textvariable=self.result_str_Var
              ).grid(row=row, column=2, rowspan=2, columnspan=3, sticky='ew')
        row += 2

        Button(self.toplevel, text='Dump To json', command=self._SaveJson
               ).grid(row=row, column=0)
        Button(self.toplevel, text='Save Image', command=self._SaveFigure
               ).grid(row=row, column=1)
        Button(self.toplevel, text='Log DPPH', command=self._LogDPPH
               ).grid(row=row, column=2)

        self._SetupPlot(row=0, column=5)

    def _SetupPlot(self, row, column):
        '''
            Initialize the plot in the gui
        '''
        self.figure = Figure()
        self.figure.subplots_adjust(left=0.15, bottom=0.2)
        self.subfigure = self.figure.add_subplot(1, 1, 1)
        self.subfigure.plot([0], [0])
        self.subfigure.plot([0], [0])
        self.subfigure.set_xlabel('Freq [MHz]')
        self.canvas = FigureCanvasTkAgg(self.figure, master=self.toplevel)
        self.canvas.show()
        self.canvas.get_tk_widget().grid(row=row, column=column, rowspan=10)

    def _CollectSweep(self):
        '''
        '''
        tmp_power = self.powerVar.get()
        if self.set_power_BoolVar.get():
            tmp_power = False
        while True:
            sweep = _GetSweptVoltages(pype=self.pype,
                                  start_freq=self.start_freq_Var.get(),
                                  stop_freq=self.stop_freq_Var.get(),
                                  sweep_time=self.sweep_time_Var.get(),
                                  power=tmp_power,
                                  num_points=self.num_points_Var.get())
            self.sweep_result = sweep.copy()
            freqdata = array(sweep['frequency_curve'])
            magdata = sweep['amplitude_curve']
            if type(magdata[0]) is unicode:
                print('Warning: _GetSweptVoltages failed;')
                print('magdata:')
                print(magdata)
                print('Acquiring data again...')
            elif type(magdata[0]) is int:
                break
        if not sweep['frequencies_confirmed']:
            showwarning('Warning', 'Communication with lockin amp failed. Frequencies data may be wrong')
        magdata = magdata - mean(magdata)
        #ydata = sweep['y_curve']
        print('freq range is ', min(freqdata), ' to ', max(freqdata))
        #xdata = sweep['x_curve']
        y_del = max((max(magdata) - min(magdata)) * .05, 1)
        self.subfigure.set_xlim(left=freqdata[0], right=freqdata[-1])
开发者ID:project8,项目名称:Pypeline,代码行数:70,代码来源:swept_dpph_gui.py


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