本文整理汇总了Python中Tkinter.BooleanVar.set方法的典型用法代码示例。如果您正苦于以下问题:Python BooleanVar.set方法的具体用法?Python BooleanVar.set怎么用?Python BooleanVar.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.BooleanVar
的用法示例。
在下文中一共展示了BooleanVar.set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MenuItem
# 需要导入模块: from Tkinter import BooleanVar [as 别名]
# 或者: from Tkinter.BooleanVar import set [as 别名]
class MenuItem(object):
def __init__(self, menu, title, **kwargs):
self._menu = menu
if kwargs.get('checkbox'):
# Checkbox menu item
self._checkvar = BooleanVar()
self._checkvar.set(kwargs.get('checked', False))
self._menu._ctrl.add_checkbutton(label=title, command=self._on_check, variable=self._checkvar)
else:
# NOTE: For whatever reason, lambdas do not work in this case...
self._menu._ctrl.add_command(label=title, command=self._on_click)
if kwargs.get('on_click'):
self.on_click = kwargs['on_click']
def _on_check(self):
"""Handler for keeping on_click virtual with checkbox option"""
self.on_click(self._checkvar.get())
def _on_click(self):
"""Handler for keeping on_click virtual"""
self.on_click()
def on_click(self):
pass
def __exit__(self, *args):
pass
def __enter__(self, *args):
return self
示例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(TclError):
v.get()
self.root.globalsetvar("name", "1.0")
with self.assertRaises(TclError):
v.get()
示例3: checkbutton_component
# 需要导入模块: from Tkinter import BooleanVar [as 别名]
# 或者: from Tkinter.BooleanVar import set [as 别名]
def checkbutton_component(self, s, r, c, init_val=False, mode=NORMAL, onvalue=-1, offvalue=-1):
'''adds a checkbutton, and its associated variable'''
if onvalue == -1:
var = BooleanVar()
var.set(init_val)
btn = Checkbutton(self,text=s, variable=var)
else:
var = StringVar()
var.set(init_val)
btn = Checkbutton(self,text=s, variable=var, onvalue=onvalue, offvalue=offvalue)
btn.grid(row=r, column=c, columnspan=2, sticky=W)
btn.config(state=mode)
return var
示例4: login_gui
# 需要导入模块: from Tkinter import BooleanVar [as 别名]
# 或者: from Tkinter.BooleanVar import set [as 别名]
def login_gui(username, password):
def get_login(evt=None):
temp_username = username_holder.get()
temp_password = password_holder.get()
if remember_login_holder.get():
logon_file = open("dep.dat", "w")
logon_file.write(encodestring(temp_username+" "+temp_password))
logon_file.close()
elif os.path.isfile("dep.dat"):
os.remove("dep.dat")
login_tk.destroy()
wrap.login(temp_username, temp_password)
overview_gui()
return
def on_checkbox_flip():
if remember_login_holder.get():
logon_file = open("dep.dat", "w")
logon_file.write(encodestring(username_holder.get()+" "+password_holder.get()))
logon_file.close()
else:
if os.path.isfile("dep.dat"):
os.remove("dep.dat")
return
login_tk = Tk()
login_tk.title("Login Window")
Label(login_tk, text="Login to GradeSpeed").pack(padx=50, pady=(10, 5))
Label(login_tk, text="Username:").pack(padx=50, pady=(5, 0))
username_holder = StringVar()
username_holder.set(username)
username_field = Entry(login_tk, textvariable=username_holder)
username_field.pack(padx=50, pady=(0, 5))
username_field.bind("<Key-Return>", get_login)
Label(login_tk, text="Password:").pack(padx=50, pady=(5, 0))
password_holder = StringVar()
password_holder.set(password)
password_field = Entry(login_tk, textvariable=password_holder, show="*")
password_field.pack(padx=50, pady=(0, 5))
password_field.bind("<Key-Return>", get_login)
remember_login_holder = BooleanVar()
remember_login_holder.set(len(username) > 0)
login_frame = Frame(login_tk)
Checkbutton(login_frame, text="Remember Logon", var=remember_login_holder, command=on_checkbox_flip).pack()
login_frame.pack(pady=5)
Button(text="Login", command=get_login).pack(padx=50, pady=(5, 10))
center_gui(login_tk)
login_tk.mainloop()
示例5: insert_checkbutton
# 需要导入模块: from Tkinter import BooleanVar [as 别名]
# 或者: from Tkinter.BooleanVar import set [as 别名]
def insert_checkbutton(self, text, frame_name, side, varname, stick=None, default=None, callback=None):
"""Inserts a check button widget in the specified frame.
ARGS:
* var: a TKinter supported variable, such as IntVar(), StrVar(),
and etc."""
# create a variable for this task
var = BooleanVar()
if default is not None:
var.set(default)
# create the widget
frame = self.frames[frame_name]
check = Checkbutton(frame, text=text, variable=var, command=callback)
check.pack(side=self.TkSide[side], anchor=stick)
# save data regarding the widget
if self.checkbuttons.get(frame_name, None) == None:
self.checkbuttons[frame_name] = {}
self.checkbuttons[frame_name][varname] = {'button':check,
'var':var}
示例6: Example
# 需要导入模块: from Tkinter import BooleanVar [as 别名]
# 或者: from Tkinter.BooleanVar import set [as 别名]
class Example(Frame):
def __init__(self,parent):
Frame.__init__(self,parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("CheckButton")
self.pack(fill=BOTH,expand=True)
self.var = BooleanVar()
self.var.set(False)
chbt = Checkbutton(self,text="Show Title",
variable=self.var,command=self.onClick)
#chbt.select()
chbt.place(x=50,y=50)
def onClick(self):
if self.var.get() == True:
self.master.title("CheckButton")
else:
self.master.title("NOT!!")
示例7: Studio
# 需要导入模块: from Tkinter import BooleanVar [as 别名]
# 或者: from Tkinter.BooleanVar import set [as 别名]
class Studio(Frame):
"""The Studio class is a GUI for the digital library."""
_meter = None
_grid = None
_dual_box = None
_auto_queue = None
_entry = None
_search_results = None
_selected_cart = None
def __init__(self):
"""Construct a Studio window."""
Frame.__init__(self)
# make the window resizable
top = self.master.winfo_toplevel()
for row in range(2, GRID_ROWS + 2):
for col in range(0, GRID_COLS):
top.rowconfigure(row, weight=1)
top.columnconfigure(col, weight=1)
self.rowconfigure(row, weight=1)
self.columnconfigure(col, weight=1)
# initialize the title
title = Label(self.master, font=FONT_TITLE, text=TEXT_TITLE)
title.grid(row=0, column=0, columnspan=GRID_COLS)
# initialize the meter
self._meter = Meter(self.master, METER_WIDTH, self._get_meter_data)
self._meter.grid(row=1, column=0, columnspan=GRID_COLS)
# initialize the cart grid
self._grid = Grid(self, GRID_ROWS, GRID_COLS, True, self._cart_start, self._cart_stop, self._cart_end, self.add_cart)
# initialize the dual box
self._dual_box = DualBox(self)
self._dual_box.grid(row=GRID_ROWS + 2, column=0, columnspan=4)
# intialize the auto-queue control
self._auto_queue = BooleanVar()
self._auto_queue.set(False)
control = Frame(self.master, bd=2, relief=Tkinter.SUNKEN)
Checkbutton(control, text=TEXT_AUTOSLOT, variable=self._auto_queue, onvalue=True, offvalue=False).pack(anchor=Tkinter.NW)
control.grid(row=GRID_ROWS + 2, column=4, columnspan=GRID_COLS - 4)
# initialize the search box, button
Label(control, font=FONT, text=TEXT_SEARCHBOX).pack(anchor=Tkinter.NW)
self._entry = Entry(control, takefocus=True, width=45)
self._entry.bind("<Return>", self.search)
# self._entry.grid(row=GRID_ROWS + 3, column=0, columnspan=5)
self._entry.pack(anchor=Tkinter.NW)
self._entry.focus_set()
button = Button(control, text=TEXT_SEARCH, command=self.search)
# button.grid(row=GRID_ROWS + 3, column=5)
button.pack(anchor=Tkinter.S)
# begin the event loop
self.master.protocol("WM_DELETE_WINDOW", self.master.destroy)
self.master.title(TEXT_TITLE)
self.master.mainloop()
def _search_internal(self):
"""Search the digital library in a separate thread."""
query = self._entry.get()
if len(query) >= 3:
print "Searching library with query \"%s\"..." % query
self._search_results = database.search_library(query)
self._dual_box.fill(self._search_results)
print "Found %d results." % len(self._search_results)
def search(self, *args):
"""Search the digital library.
:param args
"""
thread.start_new_thread(self._search_internal, ())
def select_cart(self, index):
"""Select a cart from the search results.
:param index: index of cart in search results
"""
if index is not None:
self._selected_cart = self._search_results[index]
def add_cart(self, key):
"""Add the selected cart to the grid.
:param key
"""
if not self._grid.has_cart(key) and self._selected_cart is not None:
self._grid.set_cart(key, self._selected_cart)
def _cart_start(self):
#.........这里部分代码省略.........
示例8: 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(42L)
self.assertEqual(self.root.globalgetvar("name"), true)
v.set(0L)
self.assertEqual(self.root.globalgetvar("name"), false)
v.set("on")
self.assertEqual(self.root.globalgetvar("name"), true)
v.set(u"0")
self.assertEqual(self.root.globalgetvar("name"), false)
v.set(u"on")
self.assertEqual(self.root.globalgetvar("name"), true)
示例9: MainUI
# 需要导入模块: from Tkinter import BooleanVar [as 别名]
# 或者: from Tkinter.BooleanVar import set [as 别名]
class MainUI(Frame):
"""
Main UI window for draft
"""
def __init__(self, parent, draftgame):
self.current_opponent_id = 0
self.user_pick_made = BooleanVar()
self.user_pick_made.set(False)
self.game = draftgame
self.parent = parent
Frame.__init__(self, parent)
self.grid()
self.__MainUI()
self.draft_logic()
def draft_logic(self):
if self.game.draft_style == "Linear":
self.linear_draft()
elif self.game.draft_style == "Snake":
self.snake_draft()
FinalUI(self.parent, self.game)
def linear_draft(self):
while self.game.current_round <= self.game.number_of_rounds:
if self.game.draft_position != self.game.current_position:
self.opponent_pick_logic(self.current_opponent_id)
self.current_opponent_id += 1
self.increment_position()
else:
self.user_pick_logic()
self.increment_position()
def snake_draft(self):
while self.game.current_round <= self.game.number_of_rounds:
if self.game.current_round % 2 != 0:
if self.game.draft_position != self.game.current_position:
self.opponent_pick_logic(self.current_opponent_id)
self.current_opponent_id += 1
self.increment_position()
else:
self.user_pick_logic()
self.increment_position()
else:
if self.game.draft_position != \
self.game.number_of_opponents \
- self.game.current_position + 2:
self.opponent_pick_logic(
self.game.number_of_opponents - self.current_opponent_id - 1
)
self.current_opponent_id += 1
self.increment_position()
else:
self.user_pick_logic()
self.increment_position()
def increment_position(self):
self.game.current_position += 1
if self.game.current_position > self.game.number_of_opponents + 1:
self.game.current_round += 1
self.game.current_position = 1
self.current_opponent_id = 0
self.__MainUI()
def user_pick_logic(self):
self.user_pick_made.set(False)
while not self.user_pick_made.get():
self.wait_variable(name=self.user_pick_made)
def opponent_pick_logic(self, opponent_id):
pick_made = False
pick = tkSimpleDialog.askstring(
"Opponent's pick",
"Who did your opponent pick?\nCurrent Pick: Round {0}: Pick {1}"
.format(self.game.current_round, self.game.current_position))
while not pick_made:
try:
if utils.get_player_position(pick, self.game.cursor) is not None:
position = utils.get_player_position(pick, self.game.cursor).rstrip('0123456789 ').upper()
if utils.get_player_from_table(pick, position, self.game.cursor) is not None:
utils.remove_player_from_possible_players(pick, self.game.connection, self.game.cursor)
opponent = [opponent for opponent in self.game.opponents if opponent_id == opponent.id][0]
opponent.team.append(pick)
pick_made = True
else:
pick = tkSimpleDialog.askstring(
"Opponent's pick",
#.........这里部分代码省略.........
示例10: App
# 需要导入模块: from Tkinter import BooleanVar [as 别名]
# 或者: from Tkinter.BooleanVar import set [as 别名]
class App(Frame):
def __init__(self, master=None):
self.master = master
Frame.__init__(self, master, relief=SUNKEN, bd=2)
self.gcode = []
self.slicing = False
self.printing = False
self.connected = False
self.monitorTemp = False
self.paused = False
self.sdpresent = False
self.sdlisting = False
self.sdchecking = False
self.sdprinting = False
self.sdpaused = False
self.sduploading = False
self.sdbytes = 0
self.sdmaxbytes = 0
self.insidelisting = False
self.readingFirmware = False
self.sdfiles = []
self.bedtemp = float(0)
self.bedtarget = float(0)
self.exttemp = float(0)
self.exttarget = float(0)
self.acceleration = 0
self.m114count = 0
self.speedcount = 0
self.location = [0, 0, 0, 0]
self.pausePoint = [0, 0, 0, 0]
self.percent = 0.0
self.ets = "??"
self.gcodeInfo = None
self.GCodeFile = None
self.StlFile = None
self.Profile = None
self.printStartLine = 0
self.startTime = 0
self.endTime = 0
self.elapsedTime = 0
self.FanSpeed = 0
self.FeedMultiply = 100
self.ExtrudeMultiply = 100
self.timingReport = None
self.filamentReport = None
self.measurementsReport = None
self.macroButtons = None
self.rpt1re = re.compile(" *T:([0-9\.]+) *E:[0-9\.]+ *B:([0-9\.]+)")
self.rpt2re = re.compile(" *T:([0-9\.]+) *E:[0-9\.]+ *W:.*")
self.locrptre = re.compile("^X:([0-9\.\-]+)Y:([0-9\.\-]+)Z:([0-9\.\-]+)E:([0-9\.\-]+) *Count")
self.speedrptre = re.compile("Fan speed:([0-9]+) Feed Multiply:([0-9]+) Extrude Multiply:([0-9]+)")
self.sdre = re.compile("SD printing byte *([0-9]+) *\/ *([0-9]+)")
self.printer = printcore()
self.settings = Settings()
self.settings.cmdFolder = cmd_folder
self.logger = Logger(self)
if self.settings.speedcommand is not None:
allow_while_printing.append(self.settings.speedcommand)
self.acceleration = self.settings.acceleration
self.dataLoggers = {}
for d in DLLIST:
self.dataLoggers[d] = DataLogger(self, d)
self.skeinforge = Skeinforge(self.settings)
self.slic3r = Slic3r(self.settings)
self.httpServer = RepRapServer(self, self.printer, self.settings, self.logger, self.settings.port)
self.menubar = Menu(self)
self.filemenu = Menu(self.menubar, tearoff=0)
self.menubar.add_cascade(label="File", menu=self.filemenu)
self.filemenu.add_command(label="Slice", command=self.openSTLFile)
self.filemenu.add_command(label="Load GCode", command=self.openGCodeFile)
self.slicemenuindex = self.filemenu.index("Slice")
self.loadgcodemenuindex = self.filemenu.index("Load GCode")
self.filemenu.add_separator()
self.filemenu.add_command(label="Exit", command=self.quitApp)
self.editmenu = Menu(self.menubar, tearoff=0)
self.menubar.add_cascade(label="Edit", menu=self.editmenu)
self.editmenu.add_command(label="Settings", command=self.editSettings)
self.editmenu.add_command(label="Firmware Settings", command=self.FirmwareSettings)
self.editmenu.add_separator()
self.editmenu.add_command(label=GCODE_MENU_TEXT, command=self.doGEdit, state=DISABLED)
self.slicermenu = Menu(self.menubar, tearoff=0)
self.menubar.add_cascade(label="Slicer", menu=self.slicermenu)
self.rbSlicer = StringVar()
#.........这里部分代码省略.........
示例11: FontChooser
# 需要导入模块: from Tkinter import BooleanVar [as 别名]
# 或者: from Tkinter.BooleanVar import set [as 别名]
class FontChooser( tkSimpleDialog.Dialog ):
BASIC = 1
ALL = 2
def __init__( self, parent, defaultfont=None, showstyles=None ):
self._family = StringVar( value='Century Schoolbook L')
self._sizeString = StringVar( value='20' )
self._weight = StringVar( value=tkFont.NORMAL )
self._slant = StringVar( value=tkFont.ROMAN )
self._isUnderline = BooleanVar( value=False )
self._isOverstrike = BooleanVar( value=False )
if defaultfont:
self._initialize( defaultfont )
self._currentFont = tkFont.Font( font=self.getFontTuple() )
self._showStyles = showstyles
self.sampleText = None
tkSimpleDialog.Dialog.__init__( self, parent, 'Font Chooser' )
def _initialize( self, aFont ):
if not isinstance( aFont, tkFont.Font ):
aFont = tkFont.Font( font=aFont )
fontOpts = aFont.actual( )
self._family.set( fontOpts[ 'family' ] )
self._sizeString.set( fontOpts[ 'size' ] )
self._weight.set( fontOpts[ 'weight' ] )
self._slant.set( fontOpts[ 'slant' ] )
self._isUnderline.set( fontOpts[ 'underline' ] )
self._isOverstrike.set( fontOpts[ 'overstrike' ] )
def body( self, master ):
theRow = 0
Label( master, text="Font Family" ).grid( row=theRow, column=0 )
Label( master, text="Font Size" ).grid( row=theRow, column=2 )
theRow += 1
# Font Families
fontList = ttk.Combobox( master, height=10, textvariable=self._family )
fontList.grid( row=theRow, column=0, columnspan=2, sticky=N+S+E+W, padx=10 )
rawfamilyList = list(tkFont.families( ))
rawfamilyList.sort()
# print rawfamilyList
familyList=[]
for family in rawfamilyList:
if family[0] == '@':
continue
familyList.append(family)
fontList.configure( values=familyList )
fontList.bind('<<ComboboxSelected>>', self.selectionChanged)
# Font Sizes
sizeList = ttk.Combobox( master, height=10, width=5, textvariable=self._sizeString )
sizeList.grid( row=theRow, column=2, columnspan=2, sticky=N+S+E+W, padx=10 )
sizes=[]
for size in xrange( 10,50 ):
sizes.append( str(size) )
sizeList.configure( values=sizes)
sizeList.bind('<<ComboboxSelected>>', self.selectionChanged)
# Styles
if self._showStyles is not None:
theRow += 1
if self._showStyles in ( FontChooser.ALL, FontChooser.BASIC ):
Label( master, text='Styles', anchor=W ).grid( row=theRow, column=0, pady=10, sticky=W )
theRow += 1
Checkbutton( master, text="bold", command=self.selectionChanged, offvalue='normal', onvalue='bold', variable=self._weight ).grid(row=theRow, column=0)
Checkbutton( master, text="italic", command=self.selectionChanged, offvalue='roman', onvalue='italic', variable=self._slant ).grid(row=theRow, column=1)
if self._showStyles == FontChooser.ALL:
Checkbutton( master, text="underline", command=self.selectionChanged, offvalue=False, onvalue=True, variable=self._isUnderline ).grid(row=theRow, column=2)
Checkbutton( master, text="overstrike", command=self.selectionChanged, offvalue=False, onvalue=True, variable=self._isOverstrike ).grid(row=theRow, column=3)
# Sample Text
theRow += 1
Label( master, text='Sample Text', anchor=W ).grid( row=theRow, column=0, pady=10, sticky=W )
theRow += 1
self.sampleText = Text( master, height=11, width=70 )
self.sampleText.insert( INSERT,'ABC...XYZ\nabc....xyz', 'fontStyle' )
self.sampleText.config( state=DISABLED )
self.sampleText.tag_config( 'fontStyle', font=self._currentFont )
self.sampleText.grid( row=theRow, column=0, columnspan=4, padx=10 )
def apply( self ):
self.result = self.getFontTuple( )
def selectionChanged( self, something=None ):
self._currentFont.configure( family=self._family.get(),
size=self._sizeString.get(),
#.........这里部分代码省略.........
示例12: __init__
# 需要导入模块: from Tkinter import BooleanVar [as 别名]
# 或者: from Tkinter.BooleanVar import set [as 别名]
class Tool_Path_Generator:
def __init__(self, top=None):
'''This class configures and populates the toplevel window.
top is the toplevel containing window.'''
_bgcolor = '#e6e6e6' # X11 color: 'gray85'
_fgcolor = '#000000' # X11 color: 'black'
font11 = "-size 15 -weight normal -slant roman " \
"-underline 0 -overstrike 0"
self.axial_length = DoubleVar()
self.printbed_diameter = DoubleVar()
self.final_diameter = DoubleVar()
self.filament_width_og = DoubleVar()
self.helix_angle = DoubleVar()
self.smear_factor = DoubleVar()
self.flow_rate = DoubleVar()
self.uv_offset = DoubleVar()
self.use_strong_pattern = BooleanVar()
self.axial_length.set(200.0)
self.printbed_diameter.set(10.0)
self.final_diameter.set(15.0)
self.filament_width_og.set(0.41)
self.helix_angle.set(45.0)
self.smear_factor.set(100.0)
self.flow_rate.set(0.0015)
self.uv_offset.set(32.5)
self.use_strong_pattern.set(True)
top.geometry("700x550")
top.title("SkelePrint Tool Path Generator")
top.configure(background="#e6e6e6")
top.configure(highlightbackground="#e6e6e6")
top.configure(highlightcolor="black")
self.Label7 = Label(top)
self.Label7.grid(row=0, column=0, sticky=W)
self.Label7.configure(background="#e6e6e6")
self.Label7.configure(font=font11)
self.Label7.configure(foreground="#000000")
self.Label7.configure(text='''SkelePrint Tool Path Generator''')
self.Labelframe1 = LabelFrame(top)
self.Labelframe1.grid(row=1, column=0, sticky=N+S)
self.Labelframe1.configure(relief=GROOVE)
self.Labelframe1.configure(foreground="black")
self.Labelframe1.configure(text='''Dimensions''')
self.Labelframe1.configure(background="#e6e6e6")
self.Labelframe1.configure(highlightbackground="#e6e6e6")
self.Labelframe1.configure(highlightcolor="black")
self.axial_length_entry = Entry(self.Labelframe1)
self.axial_length_entry.grid(row=0, column=1)
self.axial_length_entry.configure(background="white")
self.axial_length_entry.configure(font="TkFixedFont")
self.axial_length_entry.configure(foreground="#000000")
self.axial_length_entry.configure(highlightbackground="#e6e6e6")
self.axial_length_entry.configure(highlightcolor="black")
self.axial_length_entry.configure(insertbackground="black")
self.axial_length_entry.configure(selectbackground="#c4c4c4")
self.axial_length_entry.configure(selectforeground="black")
self.axial_length_entry.configure(textvariable=self.axial_length)
self.Label1 = Label(self.Labelframe1)
self.Label1.grid(row=0, column=0, sticky=E)
self.Label1.configure(activebackground="#e6e6e6")
self.Label1.configure(activeforeground="black")
self.Label1.configure(background="#e6e6e6")
self.Label1.configure(foreground="#000000")
self.Label1.configure(highlightbackground="#e6e6e6")
self.Label1.configure(highlightcolor="black")
self.Label1.configure(text='''Axial Length''')
self.Label2 = Label(self.Labelframe1)
self.Label2.grid(row=0, column=2, sticky=W)
self.Label2.configure(activebackground="#e6e6e6")
self.Label2.configure(activeforeground="black")
self.Label2.configure(background="#e6e6e6")
self.Label2.configure(disabledforeground="#e6e6e6")
self.Label2.configure(foreground="#000000")
self.Label2.configure(highlightbackground="#e6e6e6")
self.Label2.configure(highlightcolor="black")
self.Label2.configure(text='''mm''')
self.Label3 = Label(self.Labelframe1)
self.Label3.grid(row=1, column=0, sticky=E)
self.Label3.configure(activebackground="#e6e6e6")
self.Label3.configure(activeforeground="black")
self.Label3.configure(background="#e6e6e6")
self.Label3.configure(foreground="#000000")
self.Label3.configure(highlightbackground="#e6e6e6")
self.Label3.configure(highlightcolor="black")
self.Label3.configure(text='''Printbed Diameter''')
self.Entry2 = Entry(self.Labelframe1)
self.Entry2.grid(row=1, column=1)
self.Entry2.configure(background="white")
self.Entry2.configure(font="TkFixedFont")
self.Entry2.configure(foreground="#000000")
self.Entry2.configure(highlightbackground="#e6e6e6")
#.........这里部分代码省略.........
示例13: Plotter
# 需要导入模块: from Tkinter import BooleanVar [as 别名]
# 或者: from Tkinter.BooleanVar import set [as 别名]
class Plotter(object):
def __init__(self, fig):
self._scope = None
self.fig = fig
self.plt = fig.add_subplot(111)
self.ch1, self.ch2 = self.plt.plot([], [], [], [])
self.pool = ThreadPool()
self.ch1b = BooleanVar()
self.ch1b.set(True)
self.ch2b = BooleanVar()
self.ch2b.set(True)
self._fft = BooleanVar()
self._fft.set(False)
self._xy = BooleanVar()
self._xy.set(False)
self._USB_voltage = None
@property
def scope(self):
return self._scope
@scope.setter
def scope(self, port):
self._scope = DPScope(port)
@property
def both_channels(self):
return self.ch1b.get() and self.ch2b.get()
@property
def xy(self):
return self._xy.get()
@property
def fft(self):
return self._fft.get()
@property
def USB_voltage(self):
if not self._USB_voltage:
self.scope.adcon_from(0)
self.scope.set_dac(0, 3000)
self.scope.set_dac(1, 3000)
real_dac = sum(self.scope.measure_offset()) / 2
self.scope.set_dac(0, 0)
self.scope.set_dac(1, 0)
nominal_dac = 3 * (1023 / 5.)
self._USB_voltage = 5. * (nominal_dac / real_dac)
return self._USB_voltage
def to_volt(self, adc, gain=1, pregain=1):
multiplier = (self.USB_voltage/5.) * (20./256) * pregain * gain
return adc * multiplier
def read_volt(self):
return map(self.to_volt, self.scope.read_adc())
def poll(self):
self.arm()
self.plot(*self.parse(self.read()))
self.scope.abort()
def read(self, nofb=205):
data = None
while not data:
data = self.scope.read_back(nofb)
return data[1:] # need first byte?
def parse(self, data):
ch1 = data
ch2 = []
if self.both_channels:
ch1, ch2 = channels(data)
if self.fft:
ch1 = fft(ch1)
ch2 = fft(ch2)
if self.xy:
return ch1, ch2, [], []
else:
return [], ch1, [], ch2
def reader(self, nofb=205):
while True:
yield self.read(nofb)
def arm(self):
if self.both_channels:
self.scope.arm(0)
else:
self.scope.arm_fft(0, self.ch1b.get() or self.ch2b.get()*2)
#.........这里部分代码省略.........
示例14: cs_bln
# 需要导入模块: from Tkinter import BooleanVar [as 别名]
# 或者: from Tkinter.BooleanVar import set [as 别名]
def cs_bln(val):
bvar = BooleanVar()
bvar.set(val)
return bvar
示例15: FileNamePurifierGUI
# 需要导入模块: from Tkinter import BooleanVar [as 别名]
# 或者: from Tkinter.BooleanVar import set [as 别名]
#.........这里部分代码省略.........
purifier = FileNamePurifier(self.finalAppendToFrontText, self.finalAppendToEndText,
[self.finalRemoveFirstInstanceText], [],
[], self.ReadOldSeparatorList(), self.GetNewSeparator(), self.breakUpByBraces.get(),
self.breakUpByParens.get(),
self.breakUpByBrackets.get(), self.breakUpByCamelCase.get(),
self.oldCamelcaseButton.get(), self.camelcaseButton.get())
return purifier
def purifyFiles(self):
if(len(self.directoryText.get("0.0", END)) > 0):
selectorAndPurifier = FileSelectorAndPurifier(self.affectSubfolders.get(), self.cleanFolderNames.get(),
self.directoryText.get("0.0", END), self.CreatePurifierForOptions())
tkMessageBox.showinfo("FileNamePurifier", "Purifying FileNames. Please Wait.")
selectorAndPurifier.PurifyFileNames()
tkMessageBox.showinfo("FileNamePurifier", "FileName Purification Complete!")
def CreateOldSeparatorMenu(self):
self.oldSeparatorMenu = Menu(self.optionsMenu, tearoff=0)
self.oldSpacesButton = BooleanVar()
self.oldUnderscoresButton = BooleanVar()
self.oldCamelcaseButton = BooleanVar()
self.oldPeriodButton = BooleanVar()
self.oldSeparatorMenu.add_checkbutton(label="Spaces", onvalue=True, offvalue=False,
variable=self.oldSpacesButton)
self.oldSpacesButton.set(True)
self.oldSeparatorMenu.add_checkbutton(label="Underscores", onvalue=True, offvalue=False,
variable=self.oldUnderscoresButton)
self.oldUnderscoresButton.set(True)
#self.oldSeparatorMenu.add_command(label="Custom Separator", command=self.customSeparatorFrame)
self.oldSeparatorMenu.add_checkbutton(label="CamelCase", onvalue=True, offvalue=False,
variable=self.oldCamelcaseButton)
self.oldSeparatorMenu.add_checkbutton(label="Period", onvalue=True, offvalue=False,
variable=self.oldPeriodButton)
self.optionsMenu.add_cascade(label="Old Separator", menu=self.oldSeparatorMenu)
def addSubMenus(self):
self.CreateOldSeparatorMenu()
self.createNewSeparatorMenu()
self.addSubCheckbuttons()
self.createBreakUpByMenu()
self.createAppendTextMenu()
self.optionsMenu.add_command(label="Remove First Instance Of", command=self.removeFirstInstanceFrame)