%pip freezeHere is the code to display Jpg image over a button. You can check the status by using this command and check all installed libraries. from PIL import ImageTk, Image If PIL ( Python Image Library ) is not installed then use PIP to install it. Import tkinter as tkmy_w=tk.Tk()my_w.geometry('300x100')my_w.title('= tk.PhotoImage(file = "D:/images/top2.png") b1=tk.Button(my_w,image=my_img)b1.grid(row=1,column=1)my_w.mainloop() Read more on how to disply MySQL Blob binary data (image) using button PIL ( Python Imaging Library )To install use this command at command prompt pip install pillow Python Imaging Library : Pillow →įor. Import tkinter as tk my_w = tk.Tk()my_w.geometry("400x200") l1 = tk.Label(my_w, width=15 )l1.grid(row=1,column=1) my_img = tk.PhotoImage(file = "D:\\top2.png") l2 = tk.Label(my_w, image=my_img )l2.grid(row=1,column=2) my_w.mainloop()You may change you path based on the location of the image file in your system. Import tkinter as tkmy_w=tk.Tk()my_w.geometry('300x100')my_w.title('my_w.iconbitmap('D:\\images\\favicon.ico')my_w.mainloop() Adding image using Label Here \f can be understood as form feed, so we used two backslashes. class displaying icon or JPG PNG image in windows by using Label or button using PILLOW libraryĮscape the path by using two backslashes if you have any char with can be used with backslash. Is the base class for dialogs defined in other supporting modules. The mondialog module provides the Dialog class that Confirmation is required if an already existing file is Test whether or not the selection points to a valid file that is not aĭirectory. SaveFileDialog ( master, title = None ) ¶Ī subclass of FileDialog that creates a dialog window for selecting a Test that a file is provided and that the selection indicates anĪlready existing file. LoadFileDialog ( master, title = None ) ¶Ī subclass of FileDialog that creates a dialog window for selecting an Update the current file selection to file. quit ( how = None ) ¶Įxit dialog returning filename, if any. ok_event ( event ) ¶Įxit dialog returning current selection. go ( dir_or_file = os.curdir, pattern = '*', default = '', key = None ) ¶ Retrieve the file filter currently in use. filter_command ( event = None ) ¶įilter the files by directory. files_select_event ( event ) ¶Įvent handler for single-click event on file. files_double_event ( event ) ¶Įvent handler for double-click event on file. dirs_select_event ( event ) ¶Įvent handler for click event on directory. dirs_double_event ( event ) ¶Įvent handler for double-click event on directory. Trigger the termination of the dialog window. FileDialog ( master, title = None ) ¶Ĭreate a basic file selection dialog. The FileDialog class should be subclassed for custom event asksaveasfilename ( ** options ) ¶Ĭreate a SaveAs dialog and return the selected filename. Selected filename(s) that correspond to existing file(s). The above two functions create an Open dialog and return the askopenfilename ( ** options ) ¶ tkinter.filedialog. asksaveasfile ( mode = 'w', ** options ) ¶Ĭreate a SaveAs dialog and return a file object opened in write-only mode. The above two functions create an Open dialog and return the openedįile object(s) in read-only mode. askopenfiles ( mode = 'r', ** options ) ¶ askopenfile ( mode = 'r', ** options ) ¶ tkinter.filedialog. Wait for the user’s selection, then return the selected value(s) or None to theĬaller. The below functions when called create a modal, native look-and-feel dialog, Multiple - when true, selection of multiple items is allowed
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |