Skip to content

Commit 5ff769f

Browse files
committed
Some updates
* Update and convert to Thikter "Simple Window" example * Update and convert to Thikter "User Input Window" example
1 parent cac6173 commit 5ff769f

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

simple-window/simple-window.py

+8-13
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
# Simple Window - A simple window program
22
# Copyright (c) 2022 Ercan Ersoy
33
# This file licensed under MIT License.
4+
# Write this code using GitHub Copilot.
45

5-
import PySimpleGUI as sg
6+
import tkinter as tk
67

7-
sg.theme("SystemDefaultForReal")
8+
window = tk.Tk()
9+
window.title("Simple Window")
10+
window.geometry("300x100")
811

9-
layout = [[sg.Text("Example Message")]]
12+
label = tk.Label(window, text="Example Message")
13+
label.place(relx=0.5, rely=0.5, anchor="center")
1014

11-
window = sg.Window("Simple Window", layout, element_justification="c",
12-
size=(300, 100), finalize=True)
13-
14-
while True:
15-
event, values = window.read()
16-
17-
if event == sg.WIN_CLOSED:
18-
break
19-
20-
window.close()
15+
window.mainloop()
+17-13
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
# User Input Window - A simple user input window program
22
# Copyright (c) 2022 Ercan Ersoy
33
# This file licensed under MIT License.
4+
# Write this code using GitHub Copilot.
45

5-
import PySimpleGUI as sg
6+
import tkinter as tk
67

7-
sg.theme("SystemDefaultForReal")
8+
def on_button_click():
9+
print(input_entry.get())
10+
window.destroy()
811

9-
layout = [[sg.Text("Input:"), sg.In(size=(50, 1), key="INPUT"), sg.Button("OK")]]
12+
window = tk.Tk()
13+
window.title("User Input Window")
14+
window.geometry("400x100")
1015

11-
window = sg.Window("User Input Window", layout, element_justification="c",
12-
size=(500, 100), finalize=True)
16+
frame = tk.Frame(window)
17+
frame.pack(anchor="center")
1318

14-
while True:
15-
event, values = window.read()
19+
input_label = tk.Label(frame, text="Input")
20+
input_label.grid(row=0, column=0, sticky="w", padx=5, pady=5)
1621

17-
if event == "OK":
18-
print(values["INPUT"])
19-
break
22+
input_entry = tk.Entry(frame, width=50)
23+
input_entry.grid(row=1, column=0, padx=5, pady=5)
2024

21-
if event == sg.WIN_CLOSED:
22-
break
25+
ok_button = tk.Button(frame, text="OK", command=on_button_click)
26+
ok_button.grid(row=1, column=1, sticky="e", padx=5, pady=5)
2327

24-
window.close()
28+
window.mainloop()

0 commit comments

Comments
 (0)