H
H
Hyerin002021-11-03 12:43:37
Python
Hyerin00, 2021-11-03 12:43:37

Create child window in Pyhton with Tkinder. What is the problem?

I wanted to create a child window using Tkinder in Python.
Here is the code:
import tkinter as tk

class Main(tk.Frame):
def __init__(self, root):
super().__init__(root)
self.init_main()

def init_main(self):
toolbar = tk.Frame(bg= '#d7d8e0', bd=2)
toolbar.pack(side=tk.TOP, fill=tk.X)

self.add_img = tk.PhotoImage(file="1st form.png")
btn_open_dialog = tk.Button(toolbar, text='Apat qosu', command=self.open_dialog, bg='#d7d8e0', bd=2,
compound=tk.TOP, image=self.add_img)
btn_open_dialog.pack(side=tk.LEFT)

def open_dialog(self ):

class Child(tk.Toplevel):
def __init__(self):
super().__init__(root)
self.init_child()

def init_child(self):
self.title("Apat qosu")
self.geometry('400x220+400 +300')
self.resizable(False, False)

self.grap_set()
self.focus_set()

if __name__ == "__main__":
root = tk.Tk()
app = Main(root)
app.pack()
root. title("Alemdik Apattar Qory")
root.geometry("650x450+300+200")
root.resizable(False, False)
root.mainloop()

but my image got closer. how can i fix this? aspect ratio 16:9.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question