def write_tracklist(): root = Tk() root.withdraw() files = askopenfilenames(parent=root, title="Choose Tracks") tracklist = root.tk.splitlist(files) for to_write in tracklist: write_lyrics_with_path(to_write, True) print("Done!")
def main(): """ Main Program """ # Parser for user CLI interaction parser = ArgumentParser( description= 'Provided a list of IP addresses or URL\'s, format the proper Fortigate ' 'commands to create them and output to a file within the current working directory.\n' 'DISCLAIMER: If you run something on a firewall that you shouldn\'t have, ' 'we are NOT responsible. READ YOUR CODE BEFORE YOU PLACE IT!!!', usage='VDOM input_file.txt or .csv', formatter_class=RawTextHelpFormatter) parser.add_argument( '-v', '--VDOM', help='Specify the VDOM to which changes will be applied.\n\n', default=False) parser.add_argument( '-f', '--File', help='Accepts two kinds of files, .txt & .csv. If no file is given, ' 'the file explorer will launch and you will be prompted to select one.\n' 'Each type should be formatted differently.\n' '.txt: Each entry should be on its own line, formatted as IP/CIDR, IP/Netmask or a URL.\n' '.csv: Should consist of 5 fields. The first is required, the rest are optional:\n\n' 'IP/CIDR or URL (the CIDR prefix is optional, and just an IP can be accepted)\n' 'Netmask (needed if you do not provide a CIDR in the previous field)\n' 'Custom Name for the object\n' 'Interface to associate object to\n' 'Comment to label the object\n\n' '.csv\'s should be formatted similarly to an Excel .csv') address_or_service = parser.add_mutually_exclusive_group() address_or_service.add_argument('-a', '--address', default=True, action='store_true', help='Create address objects.') address_or_service.add_argument('-s', '--service', default=False, action='store_true', help='Create service objects.') args = parser.parse_args() # If args.File is given, proceed to launch function. Else, launch file # explorer and then proceed. if args.File: launch(args.VDOM, args.File, args.address, args.service) else: root = Tk() root.withdraw() # Prevents empty root window from displaying. launch(args.VDOM, askopenfilename(), args.address, args.service)
def fileOpenClicked(default_path): root = Tk() video_path = str( askopenfilename(filetypes=[("MP4 files", "*.mp4"), ("AVI files", "*.avi"), ("All files", "*.*")])) video_path = os.path.split(video_path)[0] + "/" + os.path.split(video_path)[1] root.destroy() if len(video_path) >= 5: print("Input file path selected by the user: "******"Error. User canceled input file selection.") print("User selected default input file path:", video_path) return video_path
def _tk_folder_selection(self) -> str: """ returns path to main folder of what the user selects via a GUI/prompt """ root = Tk() root.withdraw() path = askdirectory(title='Please select a folder') root.destroy() return path
def _tk_file_selection(self) -> str: """ returns full path of a file that the user selects via a GUI/prompt """ self.is_user_selected_directory = True root = Tk() root.withdraw() path = askopenfilename(title='Please select a file') root.destroy() return path
def importDeck(): #print("Import Deck") Tk().withdraw() #fileName = "C:/Users/walte/Downloads/Heartless Retrival 3-12.dec"#askopenfilename() fileName = askopenfilename() print(fileName) file = open(fileName, "r") extention = fileName[len(fileName) - 4:len(fileName)] print(fileName) if extention in supported: if (extention == ".dck"): return parseDck(file) elif (extention == ".dec"): return parseDec(file) else: print("Unsupported File Type --- Accepted types are:") for fileType in supported: print(fileType)
def createplay(event): global name12 global root12 root12=Tk() root12.resizable(0,0) root12.title("Create Playlist") root12.config(bg="#220047") width=400 height=150 screen_width = root12.winfo_screenwidth() screen_height = root12.winfo_screenheight() x = (screen_width/2) - (width/2) y = (screen_height/2) - (height/2) root12.geometry('%dx%d+%d+%d' % (width, height, x, y)) name12=StringVar(root12) todo1=Label(root12,text="Name your playlist",font=("roboto",20),bg="#220047",fg="#CE9141") todo1.pack() input0=Entry(root12,textvar=name12,width=50) input0.place(x=50,y=60) submit0=Button(root12,text='Submit',font=("georgia",15),width=10,fg='#220047',bg='#CE9141',activeforeground="#CE9141",activebackground="#220047",height=1,) submit0.place(x=135,y=100) submit0.bind("<Button-1>",savelist) root12.mainloop()
def login2(event): global root10 root10=Tk() root10.resizable(0,0) root10.config(bg="#220047") root10.title("Log In") width=500 height=300 screen_width = root10.winfo_screenwidth() screen_height = root10.winfo_screenheight() x = (screen_width/2) - (width/2) y = (screen_height/2) - (height/2) root10.geometry('%dx%d+%d+%d' % (width, height, x, y)) Username=StringVar() Password=StringVar() login_1=Label(root10, text="Log In",fg="#CE9141",bg="#220047",width=20,font=("georgia", 40)) login_1.place(x=-50,y=20) user2= Label(root10, text="Username",fg="#CE9141",bg="#220047",width=20,font=("georgia", 15)) user2.place(x=-10,y=115) input3=Entry(root10,textvar=Username,width=40) input3.place(x=200,y=120) pass2= Label(root10, text="Password",fg="#CE9141",bg="#220047",width=20,font=("georgia", 15)) pass2.place(x=-10,y=165) input4=Entry(root10,textvar=Password,width=40,show="**") input4.place(x=200,y=170) submit1=Button(root10,text='Submit',font=("georgia",20),width=10,fg='#220047',bg='#CE9141',activeforeground="#CE9141",activebackground="#220047",height=1,) submit1.place(x=170,y=225) submit1.bind("<Button-1>",checkdata2) back=Button(root10,text="Back",font=("georgia",10),width=10,fg='#220047',bg='#CE9141',activeforeground="#CE9141",activebackground="#220047") back.place(x=400,y=10) back.bind("<Button-1>",back3) root10.mainloop()
def importplaylist(event): #Imports an already made playlist global root11 global listofsongs global listofsongs2 global conditionalval global playlist_1 global playkey conditionalval=3 dataopen=open("PlaylistData1.dat","rb") userkey=pickle.load(dataopen) playkey=userkey[user11] dataopen.close() root11=Tk() root11.resizable(0,0) root11.config(bg="#220047") width=300 height=300 screen_width = root11.winfo_screenwidth() screen_height = root11.winfo_screenheight() x = (screen_width/2) - (width/2) y = (screen_height/2) - (height/2) root11.geometry('%dx%d+%d+%d' % (width, height, x, y)) playlist_1=Listbox(root11,selectbackground="#CE9141",height=8,width=30,relief=GROOVE,bd=3,bg="#220047",fg="#CE9141",font=("fixedsys",10)) playlist_1.place(x=20,y=70) text1_2=Label(root11,text="Playlist's for user:"******"georgia",15),bg="#220047",fg="#CE9141") text1_2.place(x=50,y=10) okay1=Button(root11,text="Select",bg="#CE9141",relief=RAISED,fg="#220047",bd=1,activebackground="#220047",activeforeground="#CE9141",font=("fixedsys",10),command=okay) okay1.place(x=120,y=230) for i in playkey: playlist_1.insert(0,i) root11.mainloop()
def error4(): global root9 root9=Tk() root9.resizable(0,0) root9.title("Error") root9.config(bg="#220047") width=450 height=230 screen_width = root9.winfo_screenwidth() screen_height = root9.winfo_screenheight() x = (screen_width/2) - (width/2) y = (screen_height/2) - (height/2) root9.geometry('%dx%d+%d+%d' % (width, height, x, y)) errortxt1=Label(root9,text="Error!",font=("georgia",30),bg="#220047",fg="#CE9141") errortxt1.place(x=162,y=7) errortxt2=Label(root9,text="No field should be left empty! Make sure you have filled \n the following fields correctly: \n 1.Username \n 2. Fullname ",font=("georgia",12),bg="#220047",fg="#CE9141") errortxt2.place(x=25,y=65) bt2=Button(root9,text="Try Again",font=("georgia",20),bg="#CE9141",fg="#220047",activebackground="#220047",activeforeground="#CE9141") bt2.place(x=160,y=155) bt2.bind("<Button-1>",tryagain4) root9.mainloop()
def error2(): global root6 root6=Tk() root6.resizable(0,0) root6.title("Error") root6.config(bg="#220047") width=450 height=200 screen_width = root6.winfo_screenwidth() screen_height = root6.winfo_screenheight() x = (screen_width/2) - (width/2) y = (screen_height/2) - (height/2) root6.geometry('%dx%d+%d+%d' % (width, height, x, y)) errortxt1=Label(root6,text="Error!",font=("georgia",30),bg="#220047",fg="#CE9141") errortxt1.place(x=165,y=7) errortxt2=Label(root6,text="The email id entered is not valid , please enter a valid email id ",font=("georgia",10),bg="#220047",fg="#CE9141") errortxt2.place(x=30,y=70) bt2=Button(root6,text="Try Again",font=("georgia",20),bg="#CE9141",fg="#220047",activebackground="#220047",activeforeground="#CE9141") bt2.place(x=165,y=120) bt2.bind("<Button-1>",tryagain2) root6.mainloop()
for col in columns: print(any(col in s for s in csv_columns[0])) def display_columnsCSV(file): csv_columns = [] with open(file, newline='') as f: reader = csv.reader(f, delimiter=';', quoting=csv.QUOTE_NONE) for row in reader: csv_columns.append(row) break print(Style.BOLD + Style.OKBLUE + str(csv_columns[0]) + Style.ENDC) Tk().withdraw() filename = askopenfilename(title="Select CSV logs file :", filetypes=(("CSV files", "*.csv"), ("all files", "*.*"))) columns = [] print("File choosen :\n" + filename) display_columnsCSV(filename) # 1 = datetime, 2 = MAC Address, 3 = SSID print("Write the column name corresponding to the" + Style.BOLD + Style.OKGREEN + " datetime : " + Style.ENDC) columns.append(input()) print("Write the column name corresponding to the" + Style.BOLD + Style.OKGREEN + " MAC address : " + Style.ENDC) columns.append(input()) print("Write the column name corresponding to the" + Style.BOLD + Style.OKGREEN + " SSID : " + Style.ENDC)
s += ET.tostring(root.find('ModelStructure')).decode('utf-8') # replace all floats s = re.sub('"[-+]?(\d+([.,]\d*)?|[.,]\d+)([eE][-+]?\d+)?"', lambda f: str(float(f[0][1:-1])), s) return s def copy_binaries(wd, fmus, binaries): primary = basename(fmus[0]) for fmu, binaries_ in zip(fmus[1:], binaries[1:]): for binary in binaries_: copytree(join(wd, basename(fmu), 'binaries', binary), join(wd, primary, 'binaries', binary)) if __name__ == '__main__': tk = Tk() tk.withdraw() fmus = askopenfilenames(title='Select FMUs to merge', filetypes=['Functional\u00A0Mockup\u00A0Unit {*.fmu}']) if len(fmus) < 2: raise ValueError('Please select multiple FMUs') # create tmp directory with TemporaryDirectory() as dir: # unpack fmus to tmp directory binaries = [] for fmu in fmus: with ZipFile(fmu, 'r') as z: z.extractall(join(dir, basename(fmu))) # add all subdirectories of "binaries" in the zip files
import tkinter as tk from tkinter import RIGHT, TOP, CENTER, X from tkinter.filedialog import Button, Tk from tkinter import filedialog import vlc # Define root root = Tk() root.title("Music Player") # Set default label text label_text = tk.StringVar() label_text.set("") def pick_music(): global music_path, label_text # Get chosen files path music_path = filedialog.askopenfilename(filetypes=(("mp3 files", "*.mp3"), ("waw files", "*.waw"))) # Set music name label text label_text.set(music_path.split("/")[-1]) # Set button states to normal stop_music_button["state"] = "normal" pause_music_button["state"] = "normal" play_music_button["state"] = "normal" def play_music(): global p # If song playing try to stop
import os import pygame from tkinter.filedialog import Tk, Button, askdirectory, Label, Listbox, LEFT, RIGHT from mutagen.id3 import ID3 root = Tk() listofsongs = [] formattedlist = [] realnames = [] index = 0 def directorychoose(): filename = askdirectory() os.chdir(filename) for file in os.listdir(filename): if file.endswith(".mp3"): realdir = os.path.realpath(file) audio = ID3(realdir) realnames.append(audio['TIT2'].text[0]) listofsongs.append(file) for file in realnames: formattedlist.append(file + "\n") pygame.mixer.init()
def mp3player(): global root5 global i global listofsongs global listofsongs2 global songlist global songname global m root5=Tk() root5.resizable(0,0) root5.title("MP3 Player") root5.config(bg="#220047") width=600 height=600 screen_width = root5.winfo_screenwidth() screen_height = root5.winfo_screenheight() x = (screen_width/2) - (width/2) y = (screen_height/2) - (height/2) root5.geometry('%dx%d+%d+%d' % (width, height, x, y)) filename = PhotoImage(file ="player.png") background_label = Label(image=filename) background_label.place(x=0, y=0, relwidth=1, relheight=1) listofsongs=[] listofsongs2=[] m=StringVar() i=0 addd=Button(root5,text="Play A Folder",bg="#CE9141",fg="#220047",activebackground="#220047",activeforeground="#CE9141",font=("georgia",25)) addd.place(x=100,y=205) addd.bind("<Button>",directory) createplay=Button(root5,text="Create Playlist",bg="#CE9141",fg="#220047",activebackground="#220047",activeforeground="#CE9141",font=("georgia",25)) createplay.place(x=100,y=285) createplay.bind("<Button>",createplaylist) importplay=Button(root5,text="Import Playlist",bg="#CE9141",fg="#220047",activebackground="#220047",activeforeground="#CE9141",font=("georgia",25)) importplay.place(x=100,y=365) importplay.bind("<Button-1>",importplaylist) root5.mainloop()
def clean_path_selection(text): root = Tk() root.withdraw() path = askdirectory(title=text, mustexist=True) root.destroy() return path
def error1(): global root4 root4=Tk() root4.title("Error1") root4.resizable(0,0) root4.config(bg="#220047") width=500 height=250 screen_width = root4.winfo_screenwidth() screen_height = root4.winfo_screenheight() x = (screen_width/2) - (width/2) y = (screen_height/2) - (height/2) root4.geometry('%dx%d+%d+%d' % (width, height, x, y)) errortxt1=Label(root4,text="Error!",font=("georgia",30),bg="#220047",fg="#CE9141") errortxt1.place(x=195,y=10) errortxt2=Label(root4,text="The error has occurred due to one of the following reasons: ",font=("georgia",10),bg="#220047",fg="#CE9141") errortxt2.place(x=55,y=70) error1=Label(root4,text="(i) The Password and Username do not match please try again . ",font=("georgia",10),bg="#220047",fg="#CE9141") error1.place(x=50,y=100) error2=Label(root4,text="(ii) The username is not registered with us please register with us . ",font=("georgia",10),bg="#220047",fg="#CE9141") error2.place(x=50,y=120) bt1=Button(root4,text="Register",font=("georgia",20),bg="#CE9141",fg="#220047",activebackground="#220047",activeforeground="#CE9141") bt1.place(x=100,y=160) bt1.bind("<Button-1>",register1) bt2=Button(root4,text="Try Again",font=("georgia",20),bg="#CE9141",fg="#220047",activebackground="#220047",activeforeground="#CE9141") bt2.place(x=250,y=160) bt2.bind("<Button-1>",tryagain1) root4.mainloop()
def clean_file_selection(text): root = Tk() root.withdraw() path = askopenfilename(title=text) root.destroy() return path
def error3(): global root7 root7=Tk() root7.resizable(0,0) root7.title("Error") root7.config(bg="#220047") width=450 height=240 screen_width = root7.winfo_screenwidth() screen_height = root7.winfo_screenheight() x = (screen_width/2) - (width/2) y = (screen_height/2) - (height/2) root7.geometry('%dx%d+%d+%d' % (width, height, x, y)) errortxt1=Label(root7,text="Error!",font=("georgia",30),bg="#220047",fg="#CE9141") errortxt1.place(x=165,y=7) errortxt2=Label(root7,text="Please fulfill the following requirements for a strong password: "******"georgia",10),bg="#220047",fg="#CE9141") errortxt2.place(x=30,y=65) errortxt3=Text(root7,font=("georgia",10),height=4,width=45,bg="#220047",fg="#CE9141") errortxt3.place(x=20,y=100) errortxt3.insert(END," 1.Password should be atleast 8 character long. \n 2.Must contain atleast one uppercase and lowercase character. \n 3.No special characters are allowed. \n 4. No whitespaces are allowed. ") bt2=Button(root7,text="Try Again",font=("georgia",20),bg="#CE9141",fg="#220047",activebackground="#220047",activeforeground="#CE9141") bt2.place(x=250,y=180) bt2.bind("<Button-1>",tryagain3) bt1=Button(root7,text="Get Password",font=("georgia",20),bg="#CE9141",fg="#220047",activebackground="#220047",activeforeground="#CE9141",command=getpass) bt1.place(x=50,y=180) root7.mainloop()
from xml.etree import ElementTree as Elem import os.path from tkinter.filedialog import askopenfilename, asksaveasfilename, Tk window = Tk() window.withdraw() window.focus_force() # tree = Elem.parse("C:\\Users\\Jason\\Desktop\\bi-dir-test.xml") tree = Elem.parse( askopenfilename(initialdir=os.path.expanduser("~/Desktop"), title="Select Palo Alto xml configuration file.")) # root_tree = tree.getroot() nat_dict = {} nat_policy_count = 0 for elem in tree.iter(tag="nat"): for rules in elem: for entry in rules: nat_policy_count += 1 rule_dic = {"bi_d": 'no'} # print(entry.tag, entry.attrib) nat_dict[entry.attrib["name"]] = rule_dic for member in entry.find("source"): nat_dict[entry.attrib["name"]]["source"] = member.text # print(member.text) for member in entry.find("destination"): nat_dict[entry.attrib["name"]]["destination"] = member.text # print(member.text)
def getpass(): global root8 x1="" b=random.randint(8,12) while b!=0: a=random.randint(0,2) if a==0: c=random.randint(48,57) chars=chr(c) x1+=chars b-=1 if a==1: c=random.randint(65,90) chars=chr(c) x1+=chars b-=1 if a==2: c=random.randint(97,122) chars=chr(c) x1+=chars b-=1 root8=Tk() root8.resizable(0,0) root8.title("Pass") root8.config(bg="#220047") width=650 height=240 screen_width = root8.winfo_screenwidth() screen_height = root8.winfo_screenheight() x = (screen_width/2) - (width/2) y = (screen_height/2) - (height/2) root8.geometry('%dx%d+%d+%d' % (width, height, x, y)) getpass=Label(root8,text="Get Password",font=("georgia",30),bg="#220047",fg="#CE9141") getpass.place(x=200,y=7) instructions=Label(root8,text="Following is a randomly generated password for your convenience , you can copy the password:"******"georgia",10),bg="#220047",fg="#CE9141") instructions.place(x=30,y=80) passwordgiven=Text(root8,font=("georgia",10),height=2,width=45,bg="#220047",fg="#CE9141") passwordgiven.place(x=120,y=120) passwordgiven.insert(END,x1) bt1=Button(root8,text="Regenerate",font=("georgia",20),bg="#CE9141",fg="#220047",activebackground="#220047",activeforeground="#CE9141") bt1.place(x=250,y=170) bt1.bind("<Button-1>",regenerate) bt2=Button(root8,text="Close",font=("georgia",10),bg="#CE9141",fg="#220047",activebackground="#220047",activeforeground="#CE9141") bt2.place(x=500,y=170) bt2.bind("<Button-1>",close) root8.mainloop()
import tkinter,json from tkinter.filedialog import Tk,Frame,Button,Listbox,Scrollbar,askopenfile from tkinter.messagebox import showinfo import utils app = Tk() ActorWithActors = {} ActorWithFilms = {} FilmsWithYears = {} def load_data(): opened_file = askopenfile(defaultextension=".json", filetypes=[("All types", ".json")]) read_json = json.loads(opened_file.read()) list_box.delete(0, tkinter.END) for item in read_json: list_box.insert(tkinter.END, item['name']) films = '' for film in item['films']: films = "{},,{}".format(films, film['title']) if film['title'] not in FilmsWithYears.keys(): FilmsWithYears[film['title']] = film['year'] ActorWithActors[item['name']] = utils.get_actors(read_json, item['films'], item['name']) ActorWithFilms[item['name']] = films.split(',,')[1:] def find_bacon_number(): selected = list_box.curselection()
def pureregister(event): global Fullname global Email global Username global Password global root3 root3=Tk() root3.resizable(0,0) root3.config(bg="#220047") root3.title("Registration Form") width=500 height=450 screen_width = root3.winfo_screenwidth() screen_height = root3.winfo_screenheight() x = (screen_width/2) - (width/2) y = (screen_height/2) - (height/2) root3.geometry('%dx%d+%d+%d' % (width, height, x, y)) Fullname=StringVar() Email=StringVar() Username=StringVar() Password =StringVar() signup_1=Label(root3, text="Sign Up",fg="#CE9141",bg="#220047",width=20,font=("georgia", 40)) signup_1.place(x=-50,y=20) back=Button(root3,text="Back",font=("georgia",10),width=10,fg='#220047',bg='#CE9141',activeforeground="#CE9141",activebackground="#220047") back.place(x=400,y=10) back.bind("<Button-1>",back1) name=Label(root3, text="FullName",fg="#CE9141",bg="#220047",width=20,font=("georgia", 15)) name.place(x=-10,y=125) input1=Entry(root3,textvar=Fullname,width=40) input1.place(x=200,y=130) email= Label(root3, text="Email",fg="#CE9141",bg="#220047",width=20,font=("georgia", 15)) email.place(x=-29,y=175) input2 = Entry(root3,textvar=Email,width=40) input2.place(x=200,y=180) user1= Label(root3,text="Username",fg="#CE9141",bg="#220047",width=20,font=("georgia", 15)) user1.place(x=-10,y=225) input3=Entry(root3,textvar=Username,width=40) input3.place(x=200,y=230) pass1= Label(root3, text="Password",fg="#CE9141",bg="#220047",width=20,font=("georgia", 15)) pass1.place(x=-10,y=275) input4=Entry(root3,textvar=Password,width=40,show="**") input4.place(x=200,y=280) submit1=Button(root3,text='Submit',font=("georgia",20),width=10,fg='#220047',bg='#CE9141',activeforeground="#CE9141",activebackground="#220047",height=1) submit1.place(x=165,y=345) submit1.bind("<Button-1>",datauser) root3.mainloop()
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.''' from tkinter.filedialog import askopenfilename, asksaveasfilename, Tk import csv #Prevent tk window from displaying root = Tk() root.withdraw() appointments = {} currentPatient = '' #Select whether to output patient # (anonymous = True) or patient name (anonymous = False) anonymous = True #Get user to select a file filename = askopenfilename(title='Select a PSS patient appointment report to analyze') temp = filename.rsplit(".", 1) #split off "txt" extension temp.insert(1, "reformat") #insert "reformat" before extension output = ".".join(temp) #join back together into one string with open(filename, 'r') as f: reformatted = []
def openSound(self): Tk().withdraw( ) # we don't want a full GUI, so keep the root window from appearing filename = askopenfilename( ) # show an "Open" dialog box and return the path to the selected file self.pathToFile = filename
import csv import datetime import os import openpyxl from openpyxl.styles import Font, PatternFill from tkinter.filedialog import askopenfilename, asksaveasfilename, Tk # from tkinter import messagebox # Tk().withdraw() # Prevents tkinter window from opening root = Tk() root.withdraw() root.focus_force() now = datetime.datetime.now().strftime("%m/%d/%Y") def mode_1_import(): """ :return: dictionary {rulename: [set(apps), set(dest_port/protocol), hit value(T/F)] """ rules_dict = None # Eliminates Pycharm Error unk_tu_dict = {} # dict for unknown tcp and udp log entries # parse ruleset and get rule names and details try: with open( askopenfilename( initialdir=os.path.expanduser("~/Desktop"), title= "Select Security Rules CSV exported from Palo Alto firewall." )) as rules_file: # with open("C:\\Users\\Jason\\Desktop\\policies.csv") as rules_file:
def MAIN(event): global root1 root1=Tk() width=700 height=250 screen_width = root1.winfo_screenwidth() screen_height = root1.winfo_screenheight() x = (screen_width/2) - (width/2) y = (screen_height/2) - (height/2) root1.geometry('%dx%d+%d+%d' % (width, height, x, y)) root1.resizable(0,0) root1.config(bg="#220047") root1.title("Welcome") filename = PhotoImage(file ="welcome.png") background_label = Label(image=filename) background_label.place(x=0, y=0, relwidth=1, relheight=1) login=Button(root1,text="Log In",font=("roboto",30),bg="#CE9141",fg="#220047",activeforeground="#b2995d",activebackground="#220047",height=1,width=10) login.place(x=60,y=120) login.bind("<Button-1>",login1) signup1=Button(root1,text="Sign Up",font=("roboto",30),bg="#CE9141",fg="#220047",activeforeground="#b2995d",activebackground="#220047",height=1,width=10) signup1.place(x=390,y=120) signup1.bind("<Button-1>",signup) root1.mainloop()
def splash(): global root0 root0= Tk() root0.lift() width=850 height=425 screen_width = root0.winfo_screenwidth() screen_height = root0.winfo_screenheight() x = (screen_width/2) - (width/2) y = (screen_height/2) - (height/2) root0.geometry('%dx%d+%d+%d' % (width, height, x, y)) filename = PhotoImage(file ="splah.png") background_label = Label(image=filename) background_label.place(x=0, y=0, relwidth=1, relheight=1) root0.overrideredirect(True) root0.after(5000, destroy1) root0.mainloop()
import openpyxl import os from sys import exit from tkinter.filedialog import askopenfilename, Tk, asksaveasfilename from tkinter import messagebox Tk().withdraw() # Prevents tkinter window from opening # This only works for panorama, need an excel sheet from regular FW csv export of nat rules and then build # different set cmds from that # Determine if this is for Panorama and define the virtual router is_panorama = input("Is this for Panorama? y or n\n") if is_panorama.lower() == "n": is_panorama = None else: dev_g = input("Enter Device Group name:\n") set_cmds_list = [] def import_workbook(): try: wbook = openpyxl.load_workbook( askopenfilename(initialdir=os.path.expanduser("~/Desktop"), title="Select Input Excel File")) return wbook except FileNotFoundError: # Handles user selecting 'Cancel' messagebox.showinfo("Process aborted", "Workbook import cancelled.") exit()
################################################################################ # Created By Kyle Krug # Created on 7/9/2019 # Created to form a tempate on how to Select a file from the computer Directory # using a diaolog box ################################################################################ from tkinter.filedialog import askopenfilename, Menu, Tk, Label root = Tk() #This is where we lauch the file manager bar. def OpenFile(): name = askopenfilename(initialdir="C:/Users/", filetypes =(("Python File", "*.py"),("All Files","*.*")), title = "Choose a file.") print(name) #Using try in case user types in unknown file or closes without choosing a file. try: with open(name,'r', newline = '') as UseFile: print(UseFile.read()) except: print("No file exists") root.title( "File Opener") root.geometry('500x500') label =Label(root, text ="Chose a File!") label.pack() #Menu Bar menu = Menu(root)