質問するログイン新規登録

質問編集履歴

2

コード全容を削除

2020/10/31 12:44

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -33,155 +33,4 @@
33
33
  15))
34
34
 
35
35
  text_area.grid(column = 0, pady = 10, padx = 10)
36
- ```
37
-
38
-
39
-
40
- コード全容
41
- ```Python3
42
- import tkinter as tk
43
- from tkinter import scrolledtext
44
- from tkinter import *
45
- from tkinter import ttk
46
- from tkinter import scrolledtext
47
-
48
- # Generate Window
49
- root = tk.Tk()
50
- # title
51
- root.title('Hotel New World')
52
- # Window Size
53
- root.geometry("800x300")
54
- #MinSixe
55
- #root.minsize(500, 500)
56
- #make Window grid 1x1
57
- # root.grid_rowconfigure(0, weight=1)
58
- root.grid_columnconfigure(0, weight=1)
59
-
60
- frame1 = tk.Frame(root, width=800, height=800,
61
- relief='flat', borderwidth=1)
62
- frame1.grid(row=0, column=0, sticky=(tk.W, tk.E))
63
- frame1.grid_columnconfigure(0, weight=1)
64
- frame1.grid_columnconfigure(1, weight=2)
65
- frame1.grid_columnconfigure(2, weight=1)
66
- frame1.grid_columnconfigure(3, weight=2)
67
- frame1.grid_columnconfigure(4, weight=1)
68
- frame1.grid_columnconfigure(5, weight=1)
69
-
70
- # Create Menu
71
- menubar = tk.Menu(root)
72
-
73
- # FileMenu
74
- filemenu = tk.Menu(menubar, tearoff=0)
75
- menubar.add_cascade(label='File', menu=filemenu)
76
- # filemenu.add_command(label='Import', command=lambda : changePage(frame1))
77
- filemenu.add_command(label='Import')
78
- filemenu.add_command(label='Export Data')
79
- filemenu.add_separator()
80
- # close button ok
81
- filemenu.add_command(label='Quit Application', command=lambda: root.destroy())
82
-
83
- # HelpMenu
84
- helpmenu = tk.Menu(menubar, tearoff=0)
85
- menubar.add_cascade(label='Help', menu=helpmenu)
86
- helpmenu.add_command(label='About Application')
87
- helpmenu.add_command(label='Developer Information')
88
-
89
- # Display Menu
90
- root.config(menu=menubar)
91
-
92
-
93
- label_name = tk.Label(frame1, text="Name", font=('', 10, "bold"))
94
- label_name.grid(row=0, column=0)
95
-
96
- entry_name = tk.Entry(frame1)
97
- entry_name.grid(row=0, column=1, sticky=(tk.W, tk.E))
98
-
99
- label_country = tk.Label(frame1, text="Country", font=('', 10, "bold"))
100
- label_country.grid(row=0, column=2)
101
-
102
- entry_country = tk.Entry(frame1)
103
- entry_country.grid(row=0, column=3, columnspan=2, sticky=(tk.W, tk.E))
104
-
105
- label_passport = tk.Label(frame1, text="Passport", font=('', 10, "bold"))
106
- label_passport.grid(row=1, column=0)
107
-
108
- entry_passport = tk.Entry(frame1)
109
- entry_passport.grid(row=1, column=1, sticky=(tk.W, tk.E))
110
-
111
- label_gender = tk.Label(frame1, text="Gender", font=('', 10, "bold"))
112
- label_gender.grid(row=1, column=2)
113
- var = tk.IntVar()
114
- tk.Radiobutton(frame1, text="Male", variable=var, value=1).grid(row=1, column=3)
115
- tk.Radiobutton(frame1, text="Female", variable=var, value=2).grid(row=1, column=4)
116
-
117
- label_from = tk.Label(frame1, text="From", font=('', 10, "bold"))
118
- label_from.grid(row=2, column=0)
119
-
120
- entry_from_start = tk.Entry(frame1)
121
- entry_from_start.grid(row=2, column=1, sticky=(tk.W, tk.E))
122
-
123
- label_to = tk.Label(frame1, text="to", font=('', 10, "bold"))
124
- label_to.grid(row=2, column=2)
125
-
126
- entry_to_end = tk.Entry(frame1)
127
- entry_to_end.grid(row=2, column=3, columnspan=2, sticky=(tk.W, tk.E))
128
-
129
- label_accomondation_type = tk.Label(frame1, text="Accomondation Type", font=('', 10, "bold"))
130
- label_accomondation_type.grid(row=3, column=0)
131
-
132
- menu_accom = tk.OptionMenu(frame1, 'Accomondations', 'Male Dorm', 'Female Form', 'Doble Room', 'Single Room')
133
- menu_accom.config(width=20)
134
- menu_accom.grid(row=3, column=1, sticky=(tk.W, tk.E))
135
-
136
- btn_book = tk.Button(frame1, text='Book Now', width=10)
137
- btn_book.grid(row=4, column=4, sticky=tk.E)
138
-
139
- btn_search = tk.Button(frame1, text='Search Entry', width=10)
140
- btn_search.grid(row=5, column=4, sticky=tk.E)
141
-
142
- btn_update = tk.Button(frame1, text='Update Entry', width=10)
143
- btn_update.grid(row=6, column=4, sticky=tk.E)
144
-
145
- btn_all = tk.Button(frame1, text='View All Entry', width=10)
146
- btn_all.grid(row=7, column=4, sticky=tk.E)
147
-
148
- btn_delete = tk.Button(frame1, text='Delete Selected Entry', width=10)
149
- btn_delete.grid(row=8, column=4, sticky=tk.E)
150
-
151
- btn_quit = tk.Button(frame1, text='Quit Application', width=10,command=lambda: root.destroy())
152
- btn_quit.grid(row=9, column=4, sticky=tk.E)
153
-
154
- root1 = Tk()
155
- root1.geometry("300x300")
156
- root1.title(" Q&A ")
157
-
158
- def Take_input():
159
- INPUT = inputtxt.get("1.0", "end-1c")
160
- print(INPUT)
161
- if(INPUT == "120"):
162
- Output.insert(END, 'Correct')
163
- else:
164
- Output.insert(END, "Wrong answer")
165
-
166
- l = Label(text = "What is 24 * 5 ? ")
167
- inputtxt = Text(root1, height = 10,
168
- width = 25,
169
- bg = "light yellow")
170
-
171
- Output = Text(root1, height = 5,
172
- width = 25,
173
- bg = "light cyan")
174
-
175
- Display = Button(root1, height = 2,
176
- width = 20,
177
- text ="Show",
178
- command = lambda:Take_input())
179
-
180
- l.pack()
181
- inputtxt.pack()
182
- Display.pack()
183
- Output.pack()
184
-
185
- # ウィンドウ表示
186
- root.mainloop()
187
36
  ```

1

コード全容を追加

2020/10/31 12:44

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -33,4 +33,155 @@
33
33
  15))
34
34
 
35
35
  text_area.grid(column = 0, pady = 10, padx = 10)
36
+ ```
37
+
38
+
39
+
40
+ コード全容
41
+ ```Python3
42
+ import tkinter as tk
43
+ from tkinter import scrolledtext
44
+ from tkinter import *
45
+ from tkinter import ttk
46
+ from tkinter import scrolledtext
47
+
48
+ # Generate Window
49
+ root = tk.Tk()
50
+ # title
51
+ root.title('Hotel New World')
52
+ # Window Size
53
+ root.geometry("800x300")
54
+ #MinSixe
55
+ #root.minsize(500, 500)
56
+ #make Window grid 1x1
57
+ # root.grid_rowconfigure(0, weight=1)
58
+ root.grid_columnconfigure(0, weight=1)
59
+
60
+ frame1 = tk.Frame(root, width=800, height=800,
61
+ relief='flat', borderwidth=1)
62
+ frame1.grid(row=0, column=0, sticky=(tk.W, tk.E))
63
+ frame1.grid_columnconfigure(0, weight=1)
64
+ frame1.grid_columnconfigure(1, weight=2)
65
+ frame1.grid_columnconfigure(2, weight=1)
66
+ frame1.grid_columnconfigure(3, weight=2)
67
+ frame1.grid_columnconfigure(4, weight=1)
68
+ frame1.grid_columnconfigure(5, weight=1)
69
+
70
+ # Create Menu
71
+ menubar = tk.Menu(root)
72
+
73
+ # FileMenu
74
+ filemenu = tk.Menu(menubar, tearoff=0)
75
+ menubar.add_cascade(label='File', menu=filemenu)
76
+ # filemenu.add_command(label='Import', command=lambda : changePage(frame1))
77
+ filemenu.add_command(label='Import')
78
+ filemenu.add_command(label='Export Data')
79
+ filemenu.add_separator()
80
+ # close button ok
81
+ filemenu.add_command(label='Quit Application', command=lambda: root.destroy())
82
+
83
+ # HelpMenu
84
+ helpmenu = tk.Menu(menubar, tearoff=0)
85
+ menubar.add_cascade(label='Help', menu=helpmenu)
86
+ helpmenu.add_command(label='About Application')
87
+ helpmenu.add_command(label='Developer Information')
88
+
89
+ # Display Menu
90
+ root.config(menu=menubar)
91
+
92
+
93
+ label_name = tk.Label(frame1, text="Name", font=('', 10, "bold"))
94
+ label_name.grid(row=0, column=0)
95
+
96
+ entry_name = tk.Entry(frame1)
97
+ entry_name.grid(row=0, column=1, sticky=(tk.W, tk.E))
98
+
99
+ label_country = tk.Label(frame1, text="Country", font=('', 10, "bold"))
100
+ label_country.grid(row=0, column=2)
101
+
102
+ entry_country = tk.Entry(frame1)
103
+ entry_country.grid(row=0, column=3, columnspan=2, sticky=(tk.W, tk.E))
104
+
105
+ label_passport = tk.Label(frame1, text="Passport", font=('', 10, "bold"))
106
+ label_passport.grid(row=1, column=0)
107
+
108
+ entry_passport = tk.Entry(frame1)
109
+ entry_passport.grid(row=1, column=1, sticky=(tk.W, tk.E))
110
+
111
+ label_gender = tk.Label(frame1, text="Gender", font=('', 10, "bold"))
112
+ label_gender.grid(row=1, column=2)
113
+ var = tk.IntVar()
114
+ tk.Radiobutton(frame1, text="Male", variable=var, value=1).grid(row=1, column=3)
115
+ tk.Radiobutton(frame1, text="Female", variable=var, value=2).grid(row=1, column=4)
116
+
117
+ label_from = tk.Label(frame1, text="From", font=('', 10, "bold"))
118
+ label_from.grid(row=2, column=0)
119
+
120
+ entry_from_start = tk.Entry(frame1)
121
+ entry_from_start.grid(row=2, column=1, sticky=(tk.W, tk.E))
122
+
123
+ label_to = tk.Label(frame1, text="to", font=('', 10, "bold"))
124
+ label_to.grid(row=2, column=2)
125
+
126
+ entry_to_end = tk.Entry(frame1)
127
+ entry_to_end.grid(row=2, column=3, columnspan=2, sticky=(tk.W, tk.E))
128
+
129
+ label_accomondation_type = tk.Label(frame1, text="Accomondation Type", font=('', 10, "bold"))
130
+ label_accomondation_type.grid(row=3, column=0)
131
+
132
+ menu_accom = tk.OptionMenu(frame1, 'Accomondations', 'Male Dorm', 'Female Form', 'Doble Room', 'Single Room')
133
+ menu_accom.config(width=20)
134
+ menu_accom.grid(row=3, column=1, sticky=(tk.W, tk.E))
135
+
136
+ btn_book = tk.Button(frame1, text='Book Now', width=10)
137
+ btn_book.grid(row=4, column=4, sticky=tk.E)
138
+
139
+ btn_search = tk.Button(frame1, text='Search Entry', width=10)
140
+ btn_search.grid(row=5, column=4, sticky=tk.E)
141
+
142
+ btn_update = tk.Button(frame1, text='Update Entry', width=10)
143
+ btn_update.grid(row=6, column=4, sticky=tk.E)
144
+
145
+ btn_all = tk.Button(frame1, text='View All Entry', width=10)
146
+ btn_all.grid(row=7, column=4, sticky=tk.E)
147
+
148
+ btn_delete = tk.Button(frame1, text='Delete Selected Entry', width=10)
149
+ btn_delete.grid(row=8, column=4, sticky=tk.E)
150
+
151
+ btn_quit = tk.Button(frame1, text='Quit Application', width=10,command=lambda: root.destroy())
152
+ btn_quit.grid(row=9, column=4, sticky=tk.E)
153
+
154
+ root1 = Tk()
155
+ root1.geometry("300x300")
156
+ root1.title(" Q&A ")
157
+
158
+ def Take_input():
159
+ INPUT = inputtxt.get("1.0", "end-1c")
160
+ print(INPUT)
161
+ if(INPUT == "120"):
162
+ Output.insert(END, 'Correct')
163
+ else:
164
+ Output.insert(END, "Wrong answer")
165
+
166
+ l = Label(text = "What is 24 * 5 ? ")
167
+ inputtxt = Text(root1, height = 10,
168
+ width = 25,
169
+ bg = "light yellow")
170
+
171
+ Output = Text(root1, height = 5,
172
+ width = 25,
173
+ bg = "light cyan")
174
+
175
+ Display = Button(root1, height = 2,
176
+ width = 20,
177
+ text ="Show",
178
+ command = lambda:Take_input())
179
+
180
+ l.pack()
181
+ inputtxt.pack()
182
+ Display.pack()
183
+ Output.pack()
184
+
185
+ # ウィンドウ表示
186
+ root.mainloop()
36
187
  ```