本文整理汇总了Python中tkinter.Tk.iconbitmap方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.iconbitmap方法的具体用法?Python Tk.iconbitmap怎么用?Python Tk.iconbitmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Tk
的用法示例。
在下文中一共展示了Tk.iconbitmap方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AdminRun
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import iconbitmap [as 别名]
class AdminRun(object):
"""Invokes the RunAsAdmin helper utility"""
def __init__(self):
"""Draw (then withdraw) root Tkinter window"""
self.main = Tk()
self.main.withdraw()
self.main.iconbitmap(const.app_icon)
def launch(self, messages):
"""Relaunch PatchIt! with administrator rights"""
# Display any message(s) properly
if messages[1:] == []:
end = ""
else:
end = "".join(messages[1:])
__admin = askyesno("Relaunch PatchIt?",
'''{0}
Would you like to relaunch PatchIt! with Administrator rights? {1}'''.format(
messages[0], end))
# User does not want to relaunch PatchIt!
if not __admin:
logging.warning("User does not want to relaunch with Admin rights")
self.main.destroy()
return False
# If user wants to relaunch
else:
logging.info("User wants to relaunch with Admin rights")
# This is the raw Python script. RunAsAdmin will not work
if (const.exe_name.endswith("py") or
const.exe_name.endswith("pyw")):
logging.warning('''This is a raw Python script ({0})
RunAsAdmin.exe cannot operate!'''.format(const.exe_name))
showerror("Running Error!",
'''You are running a raw Python script ({0}).
RunAsAdmin will not work at all.'''.format(const.exe_name))
self.main.destroy()
return False
# Launch RunAsAdmin to reload PatchIt!
else:
logging.info('''This is an exe ({0}).
Launching RunAsAdmin.exe'''.format(const.exe_name))
subprocess.call(
[os.path.join(const.app_folder, "RunAsAdmin.exe"),
const.exe_name])
# Now we close PatchIt!, and let RunAsAdmin take over
# (that is, if this is an exe)
self.main.destroy()
logging.shutdown()
raise SystemExit(0)
示例2: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import iconbitmap [as 别名]
def main(cls):
# Create the application's root.
NoDefaultRoot()
root = Tk()
# Restrict sizing and add title.
root.minsize(350, 175)
root.title('Directory Size')
# Create the application's icon.
with open('tree.ico', 'wb') as file:
file.write(zlib.decompress(base64.b64decode(ICON)))
root.iconbitmap('tree.ico')
os.remove('tree.ico')
# Configure the SizeTree object.
view = cls(root)
view.grid(row=0, column=0, sticky=NSEW)
# Setup the window for resizing.
root.grid_rowconfigure(0, weight=1)
root.grid_columnconfigure(0, weight=1)
# Enter the GUI main event loop.
root.mainloop()
示例3: App
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import iconbitmap [as 别名]
class App(object):
def __init__(self):
#настройка окружения
self.pathtoapp = path2program.abspath(".")
self.lst = [x for x in listdir(".") if ".prg" in x] #получаем список файлов с расширением prg
if len(self.lst)==0:
print("No prg file found in directory")
input()
_exit(0)
self.currentfileindex = 0 #устанавливаем индекс текущего файла
#настройка графики
self.window = Tk()
self.window.title("PRG Viewer by Novicov: "+self.pathtoapp)
w = 850
h = 500
self.window.minsize(width=w-100,height=h-100)
self.window.maxsize(width=w,height=h)
#иконка
_lst = sys_argv[0].split('\\')
self.window.iconbitmap('\\'.join(_lst[:-1])+'\\PRGViewer-logo.ico')
#ПАНЕЛИ
# self.leftframe = Frame(self.window, bg="blue", width=int(w*0.667),height=h)
self.leftframe = Frame(self.window, bg="grey", width=int(w*0.667),height=h)
# self.bottomleftframe = Frame(self.leftframe, bg="red", width=w//4, height=int(h*0.2))
self.bottomleftframe = Frame(self.leftframe, bg="grey", width=w//4, height=int(h*0.2))
# self.rightframe = Frame(self.window, bg="yellow",width=int(w*0.333),height=h)
self.rightframe = Frame(self.window, bg="dark grey",width=int(w*0.333),height=h)
#canvas
self.set_canvas( self.leftframe, bg="dark green", width=int(w*0.667),height=int(h*0.8))
# self.set_canvas( self.leftframe, bg="light green", width=100,height=100)
#кнопки
self.nextButton = Button(self.bottomleftframe,text="Next",width=10)
self.prevButton = Button(self.bottomleftframe,text="Prev",width=10)
#Список фильтров
self.Filter = PRGListBox(self.rightframe,width=w-500)
#Выбор файла платы
self.infoText = StringVar()
self.infoText.set("Current file: "+self.lst[self.currentfileindex])
self.info = Label(self.rightframe,text=self.infoText.get())
self.listFilesText = StringVar()
self.listFilesText.set("\n".join(["Files: "]+self.lst))
self.listfiles = Label(self.rightframe,text=self.listFilesText.get(),anchor="w",justify=LEFT)
self.helpText = Label(self.rightframe, text="Use Next/Prev (Pg Down/Up) buttons for change file\n"+
"Use Up,Down,Right,Left buttons for move field\n"+
"Select row in ListBox for change vision mode\n"+
"Use +/- (p/m) buttons for scaling of field",anchor="n",justify=LEFT)
def set_path_and_current(self, filename):
'''
эта функция обрабатывает полный путь до файла
'''
try:
_lst = filename.split('\\')
self.path = '\\'.join(_lst[:-2])
chdir('\\'.join(_lst[:-1]))
print(listdir("."))
self.lst = [x for x in listdir(".") if ".prg" in x]
self.currentfileindex = self.lst.index(_lst[-1])
self.infoText.set("Current file: "+self.lst[self.currentfileindex])
self.info.configure(text=self.infoText.get())
self.listFilesText.set("\n".join(self.lst))
self.listfiles.configure(text=self.listFilesText.get())
self.canvas.configure(self.lst[self.currentfileindex])
self.canvas.setdefault(reper=True)
#рисуем
self.canvas.paint()
#здесь мы создаем группу
gr = list()
for item in self.canvas.field:
print(item[2][2])
if not (item[2][2] in gr):#выделяем уникальные данные
gr.append(item[2][2])
self.Filter.lst.delete(2,END)
for item in gr:
self.Filter.lst.insert(END,item)
except IOError:
self.infoText.set("Error")
self.info.configure(text=self.infoText.get())
def set_canvas(self,master=None,height=500,width=500,bg="grey" ):
if master==None:
master=self.window
self.canvas = prgCanvas(master,height=height,width=width,bg=bg)
def nextprev(self,direction):
self.currentfileindex+=1 if abs(direction)==direction else -1
#.........这里部分代码省略.........
示例4: Tk
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import iconbitmap [as 别名]
return entries
if __name__ == '__main__':
root = Tk()
root.wm_title("Retsulc (ver 0.2) - Get clusters!")
img = Image.open(pic_path)
photo = ImageTk.PhotoImage(img)
right_panel = Frame(root)
left_panel = Frame(root)
# row_of_buttons = Frame(right_panel)
panel = Label(left_panel, image=photo)
panel.pack(side=BOTTOM, fill="both", expand="yes")
# listbox = Listbox(right_panel, width=100, height=30)
# listbox.pack(side=RIGHT, fill=BOTH)
ents = makeform(left_panel, fields)
f_ents = make_f_form(right_panel, f_fields)
ents.update(f_ents)
b2 = Button(left_panel, text='GO!', command=(lambda e=ents: gogo(e)))
b2.pack(side=BOTTOM, padx=5, pady=5)
# row_of_buttons.pack(side=BOTTOM, padx=5, pady=5)
left_panel.pack(side=LEFT, expand="yes")
right_panel.pack(side=RIGHT, expand="yes")
root.iconbitmap(r'SIA_icon.ico')
root.mainloop()
示例5: Frame
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import iconbitmap [as 别名]
right_panel = Frame(root)
left_panel = Frame(root)
row_of_buttons = Frame(right_panel)
#left panel
lab = Label(left_panel, width=40, text="Set the desired filters", anchor='w', justify=LEFT)
lab.pack(side=TOP)
panel = Label(left_panel)
panel.pack(side = "bottom", fill = "both", expand = "yes")
ents = makeform_left(left_panel, fields_retsulc)
b_dest = Button(left_panel, text='Choose destination', command=(lambda e=ents: choose_dest(e)))
b_dest.pack()
b_g = Button(left_panel, text='Green File', command=(lambda e=ents: choose_green(e)))
b_g.pack()
b_r = Button(left_panel, text='Red File', command=(lambda e=ents: choose_red(e)))
b_r.pack()
#right panel
ents2 = makeform_right(right_panel, fields_filt)
# low_panel = Frame(lef)
# buttons
b_go = Button(row_of_buttons, text='GO!', command=(lambda e=(ents, ents2): go(e)))
b_go.pack(side=RIGHT, padx=5, pady=5)
left_panel.pack(side = LEFT)
right_panel.pack(side = LEFT, expand = "yes")
row_of_buttons.pack(side=BOTTOM)
root.iconbitmap(r'SIA_icon.ico') # the icon
root.mainloop()
示例6: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import iconbitmap [as 别名]
def main():
root = Tk()
root.geometry("1000x700+50+50")
root.iconbitmap('plane.ico')
GraphicalUserInterface(root)
root.mainloop()
示例7: Label
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import iconbitmap [as 别名]
#left panel
lab = Label(left_panel, width=40, text="Choose a destination", anchor='w', justify=LEFT)
lab.pack(side=TOP)
img = Image.open(pic_path) # the photo
photo = ImageTk.PhotoImage(img)
panel = Label(left_panel, image = photo)
panel.pack(side = "bottom", fill = "both", expand = "yes")
ents = makeform(left_panel, fields)
b_dest = Button(left_panel, text='Choose destination', command=(lambda e=ents: choose_dest(e)))
b_dest.pack()
#right panel
listbox = Listbox(right_panel, width = 100, height = 30)
listbox.pack(fill=BOTH)
# low_panel = Frame(lef)
# buttons
b_add = Button(row_of_buttons, text='Add File', command=(lambda e=ents: add_files(e)))
b_delete = Button(row_of_buttons, text="Remove Selected",command=lambda lb=listbox: lb.delete(ANCHOR))
b_add.pack(side=RIGHT, padx=5, pady=5)
b_delete.pack(side=LEFT, padx=5, pady=5)
row_of_buttons.pack(side=BOTTOM, padx=5, pady=5)
left_panel.pack(side = LEFT)
right_panel.pack(side = RIGHT, expand = "yes")
b_go = Button(left_panel, text='GO!', command=(lambda e=ents: go(e, listbox)))
b_go.pack(side=BOTTOM, padx=5, pady=5)
root.iconbitmap(r'blue_flower2.ico') # the icon
root.mainloop()
示例8: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import iconbitmap [as 别名]
def main():
root = Tk()
ex = Example(root)
root.iconbitmap('ping.ico')
root.mainloop()
示例9: Application
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import iconbitmap [as 别名]
class Application(object):
def __init__(self):
self.master = Tk()
self.master.title('HTML Creator')
try:
self.master.iconbitmap('logo.ico')
except TclError:
# Pour les utilisateurs non Windows
pass
self.frame = Frame(borderwidth=1, relief='sunken')
self.frame.grid(row=0, column=0, pady=20, padx=5)
message_base = ("Bonjour, HTML Creator vous permet de créer "
"des fichiers HTML5 et CSS 3 balisés et fonctionnels en un seul "
"clic ! Vous voulez essayer ? Cliquez donc sur le bouton ci-dessous")
message_base = resize_text(message_base, 20)
self.description = Label(master=self.frame,
text=message_base,
font="Times 9")
self.description.grid(row=0, column=0)
self.button_html = Button(master=self.master,
text="Créer fichier HTML & CSS",
font="Georgia 8",
command=self.creer_fichiers)
self.button_html.grid(row=0, column=1, padx=5)
#VERSION#
Label(master = self.master,
text = '1.1',
font = 'Times 8').place(x=0,y=0)
def creer_fichiers(self):
self.creer_fichier_html()
self.creer_fichier_css()
def creer_fichier_html(self):
fichier = open(file="page.html", mode="w+")
contenu=('<!DOCTYPE html>\n<!-- Generated by HTML Creator (2016) -->\n'
'<html>\n'
' <head>\n'
' <meta charset="UTF-8"/>\n'
' <link rel="Stylesheet" href="style.css"/>\n'
' <title>Titre Page</title>\n'
' </head>\n\n'
' <body>\n'
' <header>\n </header>\n\n'
' <section>\n </section>\n\n'
' <footer>\n </footer>\n\n'
' </body>\n'
'</html>')
fichier.write(contenu)
fichier.close()
def creer_fichier_css(self):
fichier = open(file="style.css", mode="w+")
contenu = ("/* CSS generated by HTML Creator (2016) */\n\n"
"@font-face\n{\n\n}\n\n" "body\n{\n\n}\n")
fichier.write(contenu)
fichier.close()
示例10: __init__
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import iconbitmap [as 别名]
def __init__(self):
tkvar = Tk()
tkvar.resizable(0,0)
tkvar.wm_title('Dodgy')
tkvar.iconbitmap('Excl.ico')
arenasize = 40
self.xpos = int((arenasize-1)/2)
self.ypos = int((arenasize-1)/2)
self.data = ['#'*arenasize, '#'*arenasize]
for x in range(arenasize-2):
self.data[1:1] = ['#' + '.'*(arenasize-2) + '#']
self.labelframe = Frame(tkvar)
self.labelframe.grid(row=1, column=0, columnspan=100)
#Allows me to center the gui units
self.datalabel = Label(tkvar, text='\n'.join(self.data), font=('Terminal', 10))
self.datalabel.grid(row=0, column=0, columnspan=100)
self.stepslabel = Label(self.labelframe, text='0', font=('Consolas', 10))
self.stepslabel.grid(row=0, column=0)
self.collectlabel = Label(self.labelframe, text='0', font=('Consolas', 10), bg="#ccc")
self.collectlabel.grid(row=0, column=1)
self.bomblabel = Label(self.labelframe, text='0', font=('Consolas', 10))
self.bomblabel.grid(row=0, column=2)
self.phantlabel = Label(self.labelframe, text='0',font=('Consolas', 10), bg="#ccc")
self.phantlabel.grid(row=0, column=3)
self.poslabel = Label(self.labelframe, text=str(self.xpos) + " " + str(self.ypos), font=('Consolas', 10))
self.poslabel.grid(row=0, column=4)
self.helplabel = Label(tkvar, text="Press H for help ->", font=('Consolas', 8))
self.helplabel.grid(row=2, column=0, columnspan=100)
self.consolelabel = Label(tkvar, text="Welcome", font=("Terminal", 8), width=arenasize, height=4)
self.consolelabeldata = []
self.consolelabel.configure(anchor="nw", justify="left")
self.consolelabel.grid(row=3, column=0)
tkvar.bind('w', lambda data=self.data: mfresh(ymove=-1))
tkvar.bind('<Up>', lambda data=self.data: mfresh(ymove=-1))
tkvar.bind('s', lambda data=self.data: mfresh(ymove=1))
tkvar.bind('<Down>', lambda data=self.data: mfresh(ymove=1))
tkvar.bind('a', lambda data=self.data: mfresh(xmove=-1))
tkvar.bind('<Left>', lambda data=self.data: mfresh(xmove=-1))
tkvar.bind('d', lambda data=self.data: mfresh(xmove=1))
tkvar.bind('<Right>', lambda data=self.data: mfresh(xmove=1))
#tkvar.bind('c', lambda data=self.data: spawncandy())
tkvar.bind('j', lambda data=self.data: spawnbomb())
tkvar.bind('z', lambda data=self.data: spawnbomb())
tkvar.bind('k', lambda data=self.data: spawnphantom())
tkvar.bind('x', lambda data=self.data: spawnphantom())
tkvar.bind('r', lambda data=self.data: restart())
tkvar.bind('h', lambda data=self.data: helpreel())
tkvar.bind('<Control-w>', quit)
self.candylist = []
self.enemylist = []
self.bomblist = []
self.phantomlist = []
self.goldcandylist = []
self.entlist = []
self.symbols = {'char':'H', 'wall':'#', 'floor':' '}
self.stepstaken = 0
self.isdeath = False
self.candyspawnrate = 4
self.collections = 0
self.enemyspawnrate = 50
self.enemyspawnmindist = 9
self.enemydocollide = False
self.bombs = 0
self.bombcost = 4
self.phantomcost = 60
self.goldcandyflashrate = 8
self.goldcandyspawnrate = 40
self.goldcandyspawnrand = 4
self.helplabelindex = -1
self.helplabeltexts = [
"<WASD>=Movement <J>=Bomb <K>=Phantom <R>=Restart ->",
"<UDLR>=Movement <Z>=Bomb <X>=Phantom <R>=Restart ->",
"<LMB>=Movement <RMB>=Bomb <MMB>=Phantom/Restart ->",
self.symbols['char'] + " = You ->",
enemy.symbol + " = Exclamator ->",
candy.symbol + " = Candy ->",
bomb.symbol + " = Bomb ->",
"Avoid the Exclamators ->",
"Collect candy to earn bombs ->",
"Drop bombs to snare Exclamators ->",
"Deploy phantoms to distract Exclamators ->",
"Phantoms have a minimum cost of " + str(self.phantomcost) + " ->",
#.........这里部分代码省略.........
示例11: Xls2kml
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import iconbitmap [as 别名]
class Xls2kml(object):
'''
Interface builted in Tkinter()
'''
def __init__(self):
'''
None -> None
Builds the Tkinter window and all his elements.
'''
# variables ----------------------------------------------------
# log file
open("erros.log", "w").close() # to open and clean the logfile
logging.basicConfig(level=logging.DEBUG, filename='erros.log')
sys.stderr = LogFile('stderr') # Redirect stderr
self.original_working_dir = os.getcwd() # original working dir
self.master = Tk() # Tk() object
self.master.title('EXCEL to KMZ Transformer - ver. 1.6') # window name
icons = os.getcwd() + os.sep + "icons" + os.sep # path to icons
foto_folder = os.getcwd() + os.sep + "fotos" # path to fotos
icon = icons + "compass.ico"
self.master.iconbitmap(icon) # window icon
self.master.resizable(width=FALSE, height=FALSE)
self.master.geometry("548x314")
self.file_name = "" # the name of the EXEL file
self.last_dir = "C:/"
# image to decorate the window
self.img = ImageTk.PhotoImage(Image.open(icons + "excel-kmz.jpg"))
# to use in frame, message, labels and buttons -----------------
self.message = StringVar()
self.message.set("\nSelecciona um ficheiro EXCEL")
bg = "gray25"
bg1 = "dark orange"
fc = "white smoke"
font = ("Helvetica", "8", "bold")
text0 = " ----- " # " ------------------------------------------ "
text1 = " Boris & Vladimir Software "
text = text0 + text1 + text0
# Menu ---------------------------------------------------------
self.menu = Menu(self.master)
self.master.config(menu=self.menu)
filemenu = Menu(self.menu)
self.menu.add_cascade(label="Ficheiro", menu=filemenu)
filemenu.add_command(label="Sair", command=self.__callback_3)
filemenu.add_command(label='Pasta Fotos', command=lambda: (self.__open_folder(foto_folder)))
# --------------------- NOVO -----------------------------------
self.openGE = BooleanVar() # não esquecer de importar BooleanVar
self.openGE.set(False)
optionsmenu = Menu(self.menu)
self.menu.add_cascade(label="Opções", menu=optionsmenu)
optionsmenu.add_checkbutton(label="Não abrir o Google Earth",
onvalue=True, offvalue=False,
variable=self.openGE)
docsmenu = Menu(self.menu)
docs = ["docs\manual.pdf", "docs\icons.pdf", "docs\colors.pdf",
"docs\GPS.xlsx", "docs\GPS.kmz", "docs\Celulas.xlsx",
"docs\Celulas.kmz", "docs\Foto.xlsx", "docs\Foto.kmz",
"docs\Quadrado.xls", "docs\Quadrado.kmz"]
self.menu.add_cascade(label="Documentação", menu=docsmenu)
docsmenu.add_command(label="Manual",
command=lambda: (self.__open_file(docs[0])))
docsmenu.add_command(label="Ícones",
command=lambda: (self.__open_file(docs[1])))
docsmenu.add_command(label="Cores",
command=lambda: (self.__open_file(docs[2])))
exemplemenu = Menu(docsmenu)
docsmenu.add_cascade(label="Exemplos", menu=exemplemenu)
gpsmenu = Menu(exemplemenu)
exemplemenu.add_cascade(label="Trajetos", menu=gpsmenu)
gpsmenu.add_command(label="Excel",
command=lambda: (self.__open_file(docs[3])))
gpsmenu.add_command(label="Google Earth",
command=lambda: (self.__open_file(docs[4])))
cellmenu = Menu(exemplemenu)
exemplemenu.add_cascade(label="Células Telefónicas", menu=cellmenu)
cellmenu.add_command(label="Excel",
command=lambda: (self.__open_file(docs[5])))
cellmenu.add_command(label="Google Earth",
command=lambda: (self.__open_file(docs[6])))
fotomenu = Menu(exemplemenu)
exemplemenu.add_cascade(label="Fotos", menu=fotomenu)
fotomenu.add_command(label="Excel",
command=lambda: (self.__open_file(docs[7])))
fotomenu.add_command(label="Google Earth",
command=lambda: (self.__open_file(docs[8])))
squaremenu = Menu(exemplemenu)
exemplemenu.add_cascade(label="Quadrado", menu=squaremenu)
squaremenu.add_command(label="Excel",
command=lambda: (self.__open_file(docs[9])))
squaremenu.add_command(label="Google Earth",
command=lambda: (self.__open_file(docs[10])))
helpmenu = Menu(self.menu)
#.........这里部分代码省略.........