本文整理汇总了Python中tkinter.Tk.withdraw方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.withdraw方法的具体用法?Python Tk.withdraw怎么用?Python Tk.withdraw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Tk
的用法示例。
在下文中一共展示了Tk.withdraw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tkinter_clipboard_get
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import withdraw [as 别名]
def tkinter_clipboard_get():
""" Get the clipboard's text using Tkinter.
This is the default on systems that are not Windows or OS X. It may
interfere with other UI toolkits and should be replaced with an
implementation that uses that toolkit.
"""
try:
from tkinter import Tk, TclError # Py 3
except ImportError:
try:
from Tkinter import Tk, TclError # Py 2
except ImportError:
raise TryNext("Getting text from the clipboard on this platform "
"requires Tkinter.")
root = Tk()
root.withdraw()
try:
text = root.clipboard_get()
except TclError:
raise ClipboardEmpty
finally:
root.destroy()
text = py3compat.cast_unicode(text, py3compat.DEFAULT_ENCODING)
return text
示例2: add_extra_content_to_data_table
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import withdraw [as 别名]
def add_extra_content_to_data_table(self, data_table):
# Read in multiple data tables
data_table_names = []
# while True:
# data_table_name = input("Which database tables are you going to pull data from (press Enter to end): ")
# if data_table_name == "":
# break
# data_table_names.append(data_table_name)
root = Tk()
root.withdraw()
data_table_name = simpledialog.askstring("Action",
"Add datatable name for this template. Press cancel to end inputting")
while True:
if data_table_name is None:
break
data_table_names.append(data_table_name)
data_table_name = simpledialog.askstring("Action",
"Add another datatable name for this template. Press cancel to end inputting")
root.destroy()
content = ["", data_table.DATA_TABLE_KEY] + data_table_names
data_table.content.append(content)
self.source.data_table_names = data_table_names
示例3: SelectDataFiles
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import withdraw [as 别名]
def SelectDataFiles():
"""Select the files to compress into a JAM"""
# Draw (then withdraw) the root Tk window
logging.info("Drawing root Tk window")
root = Tk()
logging.info("Withdrawing root Tk window")
root.withdraw()
# Overwrite root display settings
logging.info("Overwrite root settings to basically hide it")
root.overrideredirect(True)
root.geometry('0x0+0+0')
# Show window again, lift it so it can recieve the focus
# Otherwise, it is behind the console window
root.deiconify()
root.lift()
root.focus_force()
# The files to be compressed
jam_files = filedialog.askdirectory(
parent=root,
title="Where are the extracted LEGO.JAM files located?"
)
if not jam_files:
root.destroy()
colors.text("\nCould not find a JAM archive to compress!",
color.FG_LIGHT_RED)
main()
# Compress the JAM
root.destroy()
BuildJAM(jam_files)
示例4: file_chooser
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import withdraw [as 别名]
def file_chooser():
root = Tk()
root.files = filedialog.askopenfilenames(title='Choose files')
if len(files) == 1:
files = files[0]
root.withdraw()
return root.files
示例5: downloadplaylist
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import withdraw [as 别名]
def downloadplaylist(url):
print("Give a download location")
root = Tk()
root.withdraw()
filename = filedialog.askdirectory()
playlist = pafy.get_playlist(url)
playlen = len(playlist['items'])
i=0
while i < playlen:
pafyobj = playlist['items'][i]['pafy']
aobj = pafyobj.getbest()
print("---------------------------------------------------------")
print("Now Downloading: "+pafyobj.title)
print("Size is: %s" % aobj.get_filesize)
print("Video Resolution is: "+aobj.resolution)
fileloc = aobj.download(filepath=filename,quiet=False)
print("Videos downloaded at: "+filename)
print("Do you want to open the download location?\n1.Yes\n2.No")
ch = int(input())
if ch == 1:
os.startfile(filename)
else:
print("Thank you for using this script!")
print("EAT................SLEEP..................CODE...................REPEAT")
示例6: get
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import withdraw [as 别名]
def get():
r = Tk()
r.withdraw()
returnValue = r.selection_get(selection = "CLIPBOARD")
r.destroy()
return returnValue if returnValue else ''
示例7: save
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import withdraw [as 别名]
def save():
root = Tk()
root.withdraw()
filename = filedialog.asksaveasfilename( filetypes = [("JSON files", ".json"),("All files", "*")],defaultextension='.json')
if filename:
d = {'points':[], 'lines':[]}
for ppp in range(1,len(Point.points)):
p = Point.points[ppp]
pd = {
'pos': {'x': p.pos.x, 'y': p.pos.y},
'pinned' : p.pinned,
'size' : p.size,
'isMotor' : p.isMotor,
'spinPos': p.spinPos if p.spinPos == None else {'x': p.spinPos.x, 'y': p.spinPos.y},
'spinSpeed' : p.spinSpeed,
'currentSpin' : p.currentSpin
}
d['points'].append(pd)
for s in Stick.sticks:
sd = {
'p1': save_helper_point_finder(s.p1),
'p2': save_helper_point_finder(s.p2),
'visible' : s.visible
}
d['lines'].append(sd)
f = open(filename, 'w')
f.write(jsonDump(d, indent = 4))
f.close()
示例8: add
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import withdraw [as 别名]
def add(str): # TODO: for linux adds some bad data, that breaks program (breaks even editor), but for windows worked
if _platform == "win32" or _platform == "win64":
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append('i can has clipboardz?')
r.destroy()
示例9: SystemNameClip
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import withdraw [as 别名]
class SystemNameClip(object):
"""
A cross-platform wrapper for copying system names into
the clipboard such that they can be pasted into the E:D
galaxy search - which means forcing them into lower case
because E:D's search doesn't work with upper case
characters.
"""
def __init__(self):
self.tkroot = Tk()
self.tkroot.withdraw()
def strip(self, text, trailing):
if text.endswith(trailing):
text = text[:-len(trailing)].strip()
return text
def copy_text(self, text):
""" Copies the specified text into the clipboard. """
text = text.lower().strip()
text = self.strip(text, "(fix)")
text = self.strip(text, "(fixed)")
self.tkroot.clipboard_clear()
self.tkroot.clipboard_append(text.lower())
示例10: load
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import withdraw [as 别名]
def load():
root = Tk()
root.withdraw()
root.filename = filedialog.askopenfilename(title = "choose your file",
filetypes = [("JSON files", ".json"),("All files", "*")])
pbackup = None
sbackup = None
with open(root.filename, 'r') as myfile:
data=myfile.read()
try:
d = jsonLoad(data)
pbackup = Point.points[1:]
sbackup = Stick.sticks[:]
del Point.points[1:]
del Stick.sticks[:]
for p in d['points']:
a = Point(Vector2(p['pos']['x'], p['pos']['y']), p['size'], p['pinned'])
if p['isMotor']:
a.motorize(Vector2(p['spinPos']['x'], p['spinPos']['y']), p['spinSpeed'], p['currentSpin'])
a.currentSpin = p['currentSpin']
for s in d['lines']:
b = Stick(Point.points[s['p1']], Point.points[s['p2']], s['visible'])
except Exception:
messagebox.showinfo("Error", "Invalid JSON")
if pbackup and sbackup:
Point.points += pbackup
Stick.sticks += sbackup
示例11: output
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import withdraw [as 别名]
def output(self, reportfile):
fp = open(reportfile, "w")
fp.write("<?xml version=\"1.0\" ?>\n")
fp.write("<UIMacro>\n")
r = Tk()
r.withdraw()
r.clipboard_clear()
items = ["Build", "Benchmark", "Scenario", "Test", "Index", "Key", "ResponseTime", "FPS"]
actions = self._Data.findall("UIAction")
for action in actions:
s = " <UIAction"
for item in items:
s += " %s=\"%s\"" %(item , action.get(item))
s += "/>\n"
fp.write(s)
#Send the data to the clipboard
line=action.get(items[0])
for item in items[1:]:
line += "\t" + action.get(item)
line += "\n"
r.clipboard_append(line)
r.destroy()
fp.write("</UIMacro>")
fp.close()
示例12: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import withdraw [as 别名]
def main():
logging_level = logging.DEBUG
logging.Formatter.converter = time.gmtime
log_format = '%(asctime)-15s %(levelname)s:%(message)s'
logging.basicConfig(format=log_format, datefmt='%Y/%m/%d %H:%M:%S UTC', level=logging_level,
handlers=[logging.FileHandler('testparsedasbin.log'), logging.StreamHandler()])
logging.info('_____ Started _____')
t_step = 5 #60
home = os.path.expanduser('~')
start_dir = home
status = []
root = Tk()
root.withdraw() # this will hide the main window
list_of_bin_files = filedialog.askopenfilenames(filetypes=('binary {*.bin}', 'Binary files'),
initialdir = start_dir, initialfile = '')
for i in list_of_bin_files:
logging.info('processing ' + i)
status.append(pdb.parse_bin_files_to_text_files(in_filename=i, verbose_flag=True, dtm_format=True,
time_step = t_step))
if status[-1] < 256:
if status[-1] > 0:
messagebox.showwarning('Warning', 'Parsing of ' + i + ' ended with warning code ' + str(status[-1])
+ '.')
else:
messagebox.showerror('Error', 'Parsing of ' + i + ' ended with error code '+ str(status[-1]) + '!')
logging.info('______ Ended ______')
示例13: getFilenames
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import withdraw [as 别名]
def getFilenames(title, types=[], initialdir=None):
root = Tk()
root.withdraw()
filenames = filedialog.askopenfilenames(title=title, filetypes=types,
initialdir=initialdir)
root.destroy()
return root.tk.splitlist(filenames)
示例14: getFilename
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import withdraw [as 别名]
def getFilename(title, types, initialdir=None):
root = Tk()
root.withdraw()
filename = filedialog.askopenfilename(title=title, filetypes=types,
initialdir=initialdir)
root.destroy()
return filename
示例15: before_write_instru_info
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import withdraw [as 别名]
def before_write_instru_info(self, instru_info: InstruInfoComponent):
super().before_write_instru_info(instru_info)
root = Tk()
root.withdraw()
name = simpledialog.askstring("Action", "Enter NDAR instrument name (without version and not case sensitive)")
version = simpledialog.askstring("Action", "Enter NDAR instrument version")
respondent = simpledialog.askstring("Action", "Enter the respondent for this instrument. (e.g, twin, cotwin)")
if name is not None:
# No input check right now
name = name.lower()
instru_info.instru_info.instru_name = name
self.instru_info.instru_name = name
if version is not None:
# A '0' is added to the version string because NDAR requires
# single digit versions numbers to have a leading '0'
if len(version) == 1:
version = "0" + version
instru_info.instru_info.version = version
self.instru_info.version = version
if respondent is not None:
instru_info.instru_info.respondent = respondent
self.instru_info.respondent = respondent
root.destroy()