我认为我做错了,我需要互联网来纠正我。 我本打算在根目录的GUI窗口中放置一个图标。 我的代码如下:
这是我尝试做的软件
#!/usr/bin/env python3
######################################
# STAR LABS BIOSCIENCE PRIVATE LIMITED
# BRAINTECH PRIVATE LIMITED
# JOHN MELODY MELISSA
######################################
# This is a copyrighted script.
# All rights reserved © 2019 BRAINTECH.
######################################
import os
import time
import tkinter as tk
from tkinter import ttk
from tkinter import *
import pygame as game
import webbrowser
import numpy as np
from glob import glob
# TK's :
from tkinter import Tk, Frame, Menu
import pyscreenshot as ImageGrab
from pathlib import Path
import subprocess
import PIL.Image, PIL.ImageTk
from PIL import ImageTk, Image
from tkinter import messagebox as msgbox
#Folders and files:
from about import About
# Main Root Window (MRW) Declaration:
#root = tk.Tk()
#root.resizable(False, False) #<===do not uncomment=== not_recommended => not UI Friendly
#root.attributes("-fullscreen", False)
#root.geometry("1500x800")
#root.wm__iconbitmap("") # ONLY WORK WELL WITH .ico
#root.title("CEREBRALES")
# Start up tune
#game.mixer.init()
#game.mixer.music.load("Media\startup.mp3")
#game.mixer.music.play(1)
#game.mixer.stop()
class cerebro(Frame):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
#STARTUP tone:
#game.mixer.init()
#game.mixer.music.load("Media\startup.mp3")
#game.mixer.music.play(1)
#game.mixer.stop()
self.master.title("CEREBRALES")
#self.master.wm_iconphoto("cerebrales.ico")
menubar = Menu(self.master)
self.master.config(menu=menubar)
fileMenu = Menu(menubar, tearoff=0)
editMenu = Menu(menubar, tearoff=0)
connectMenu = Menu(menubar, tearoff=0)
optionMenu = Menu(menubar, tearoff=0)
windowMenu = Menu(menubar, tearoff=0)
assecMenu = Menu(menubar, tearoff=0)
helpMenu = Menu(menubar, tearoff=0)
# [FILE] Menu:
menubar.add_cascade(label="File", menu=fileMenu)
fileMenu.add_command(label="Print", command=self.prtSc)
fileMenu.add_command(label="Exit", command=self.onExit)
# [EDIT] Menu:
menubar.add_cascade(label="Edit", menu=editMenu)
editMenu.add_command(label="Export") #command=export
# [CONNECT] Menu:
menubar.add_cascade(label="Connect", menu=connectMenu)
# [OPTION] Menu:
# [Window] Menu:
menubar.add_cascade(label="Window", menu=windowMenu)
# windowMenu.add_command(label="Enter Fullscreen", command=fullscreen())
# [assec0] Menu:
# [HELP] Menu:
menubar.add_cascade(label="Help", menu=helpMenu)
helpMenu.add_command(label="About", command=self.about)
def onExit(self):
self.quit()
def prtSc(self):
im = ImageGrab.grab()
im.save("cerebrales_screen.png")
im.show()
# Alteration needed
def about(runfile):
root = tk.Tk()
#os.startfile(r"about\About.py 1")
#About.main()
msgbox.showinfo("About"," \"Cerebrales\" is a brainwave analysis software \n developed by Braintech Private Limited.\n\n CREDITS:\n\nDR ZAID ALYASSERI - BRAIN COMPUTER RESEARCHER\nDR ANG JIA YI - EMBEDDED ENGINEER\nJOHN MELODY MELISSA - SOFTWARE ENGINEER\nDR WENDY BONG - ASSISTANT DIRECTOR \n\n\n All Right Reserved © Braintech Private Limited ")
#root.tk.TK.call('wm', 'iconphoto', root._w, PhotoImage(file='logo.ico'))
# def fullscreen():
# fullscreen.fullscreen()
def main():
root = tk.Tk()
#root.resizable(False, False) #<===do not uncomment=== not_recommended => not UI Friendly
root.attributes("-fullscreen", False)
root.geometry("1500x800")
root.wm_iconbitmap("logo.ico")
app = cerebro()
#cerebro.master.iconbitmap('cerebrales 48x48.ico')
root.mainloop()
if __name__ == '__main__':
main()
我收到的错误:
Exception has occurred: TclError
bitmap "logo.ico" not defined
File "C:\Users\John Melody\Documents\MEGAsync\Cebebrales-Braintech\main.py", line 110, in main
root.wm_iconbitmap("logo.ico")
File "C:\Users\John Melody\Documents\MEGAsync\Cebebrales-Braintech\main.py", line 117, in <module>
main()
这是我确实想念的东西吗?还是我编码错了?我希望图标可以在每个窗口中运行