Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# ------------------ ok button -------------------------------
okButton = tk.Button(buttonsFrame, takefocus=1, text="OK")
bindArrows(okButton)
okButton.pack(
expand=1, side=tk.LEFT, padx='3m', pady='3m', ipadx='2m', ipady='1m')
# for the commandButton, bind activation events to the activation event
# handler
commandButton = okButton
handler = __enterboxGetText
for selectionEvent in global_state.STANDARD_SELECTION_EVENTS:
commandButton.bind("<{}>".format(selectionEvent), handler)
# ------------------ cancel button -------------------------------
cancelButton = tk.Button(buttonsFrame, takefocus=1, text="Cancel")
bindArrows(cancelButton)
cancelButton.pack(
expand=1, side=tk.RIGHT, padx='3m', pady='3m', ipadx='2m', ipady='1m')
# for the commandButton, bind activation events to the activation event
# handler
commandButton = cancelButton
handler = __enterboxCancel
for selectionEvent in global_state.STANDARD_SELECTION_EVENTS:
commandButton.bind("<{}>".format(selectionEvent), handler)
# ------------------- time for action! -----------------
entryWidget.focus_force() # put the focus on the entryWidget
boxRoot.deiconify()
boxRoot.mainloop() # run it!
# -------- after the run has completed ----------------------------------
def create_cancel_button(self):
cancelButton = tk.Button(self.buttonsFrame, takefocus=tk.YES,
text="Cancel", height=1, width=6)
bindArrows(cancelButton)
cancelButton.pack(expand=tk.NO, side=tk.LEFT, padx='2m', pady='1m',
ipady="1m", ipadx="2m")
cancelButton.bind("", self.cancel_pressed)
cancelButton.bind("", self.cancel_pressed)
# self.cancelButton.bind("", self.cancel_pressed)
selectAllButton = tk.Button(
self.buttonsFrame, text="Select All", height=1, width=6)
selectAllButton.pack(expand=tk.NO, side=tk.LEFT, padx='2m',
pady='1m',
ipady="1m", ipadx="2m")
clearAllButton = tk.Button(self.buttonsFrame, text="Clear All",
height=1, width=6)
clearAllButton.pack(expand=tk.NO, side=tk.LEFT,
padx='2m', pady='1m',
ipady="1m", ipadx="2m")
selectAllButton.bind("", self.choiceboxSelectAll)
bindArrows(selectAllButton)
clearAllButton.bind("", self.choiceboxClearAll)
bindArrows(clearAllButton)
# --------- entryWidget ----------------------------------------------
entryWidget = tk.Entry(entryFrame, width=40)
bindArrows(entryWidget)
entryWidget.configure(
font=(global_state.PROPORTIONAL_FONT_FAMILY, global_state.TEXT_ENTRY_FONT_SIZE))
if mask:
entryWidget.configure(show=mask)
entryWidget.pack(side=tk.LEFT, padx="3m")
entryWidget.bind("", __enterboxGetText)
entryWidget.bind("", __enterboxCancel)
# put text into the entryWidget
entryWidget.insert(0, __enterboxDefaultText)
# ------------------ ok button -------------------------------
okButton = tk.Button(buttonsFrame, takefocus=1, text="OK")
bindArrows(okButton)
okButton.pack(
expand=1, side=tk.LEFT, padx='3m', pady='3m', ipadx='2m', ipady='1m')
# for the commandButton, bind activation events to the activation event
# handler
commandButton = okButton
handler = __enterboxGetText
for selectionEvent in global_state.STANDARD_SELECTION_EVENTS:
commandButton.bind("<{}>".format(selectionEvent), handler)
# ------------------ cancel button -------------------------------
cancelButton = tk.Button(buttonsFrame, takefocus=1, text="Cancel")
bindArrows(cancelButton)
cancelButton.pack(
expand=1, side=tk.RIGHT, padx='3m', pady='3m', ipadx='2m', ipady='1m')
def create_ok_button(self):
self.buttonsFrame = tk.Frame(self.boxRoot)
self.buttonsFrame.pack(side=tk.TOP, expand=tk.YES, pady=0)
# put the buttons in the self.buttonsFrame
okButton = tk.Button(self.buttonsFrame, takefocus=tk.YES,
text="OK", height=1, width=6)
bindArrows(okButton)
okButton.pack(expand=tk.NO, side=tk.RIGHT, padx='2m', pady='1m',
ipady="1m", ipadx="2m")
# for the commandButton, bind activation events
okButton.bind("", self.ok_pressed)
okButton.bind("", self.ok_pressed)
okButton.bind("", self.ok_pressed)
entryFrame.pack(side=tk.TOP, fill=tk.BOTH)
# ------------- define the buttonsFrame ---------------------------------
buttonsFrame = tk.Frame(master=boxRoot)
buttonsFrame.pack(side=tk.TOP, fill=tk.BOTH)
# -------------------- the msg widget ----------------------------
messageWidget = tk.Message(messageFrame, width="4.5i", text=msg)
messageWidget.configure(
font=(global_state.PROPORTIONAL_FONT_FAMILY, global_state.PROPORTIONAL_FONT_SIZE))
messageWidget.pack(
side=tk.RIGHT, expand=1, fill=tk.BOTH, padx='3m', pady='3m')
# --------- entryWidget ----------------------------------------------
entryWidget = tk.Entry(entryFrame, width=40)
bindArrows(entryWidget)
entryWidget.configure(
font=(global_state.PROPORTIONAL_FONT_FAMILY, global_state.TEXT_ENTRY_FONT_SIZE))
if mask:
entryWidget.configure(show=mask)
entryWidget.pack(side=tk.LEFT, padx="3m")
entryWidget.bind("", __enterboxGetText)
entryWidget.bind("", __enterboxCancel)
# put text into the entryWidget
entryWidget.insert(0, __enterboxDefaultText)
# ------------------ ok button -------------------------------
okButton = tk.Button(buttonsFrame, takefocus=1, text="OK")
bindArrows(okButton)
okButton.pack(
expand=1, side=tk.LEFT, padx='3m', pady='3m', ipadx='2m', ipady='1m')
return
selectAllButton = tk.Button(
self.buttonsFrame, text="Select All", height=1, width=6)
selectAllButton.pack(expand=tk.NO, side=tk.LEFT, padx='2m',
pady='1m',
ipady="1m", ipadx="2m")
clearAllButton = tk.Button(self.buttonsFrame, text="Clear All",
height=1, width=6)
clearAllButton.pack(expand=tk.NO, side=tk.LEFT,
padx='2m', pady='1m',
ipady="1m", ipadx="2m")
selectAllButton.bind("", self.choiceboxSelectAll)
bindArrows(selectAllButton)
clearAllButton.bind("", self.choiceboxClearAll)
bindArrows(clearAllButton)