レイアウトに問題はありますが、ScrollTextは実装できました
Python3
1import tkinter as tk
2from tkinter import scrolledtext
3from tkinter import *
4from tkinter import ttk
5from tkinter import scrolledtext
6
7# Generate Window
8root = tk.Tk()
9# title
10root.title('Hotel New World')
11# Window Size
12root.geometry("800x300")
13#MinSixe
14#root.minsize(500, 500)
15#make Window grid 1x1
16# root.grid_rowconfigure(0, weight=1)
17root.grid_columnconfigure(0, weight=1)
18
19frame1 = tk.Frame(root, width=1000, height=1000,
20 relief='flat', borderwidth=1)
21frame1.grid(row=0, column=0, sticky=(tk.W, tk.E))
22frame1.grid_columnconfigure(0, weight=1)
23frame1.grid_columnconfigure(1, weight=2)
24frame1.grid_columnconfigure(2, weight=1)
25frame1.grid_columnconfigure(3, weight=2)
26frame1.grid_columnconfigure(4, weight=1)
27frame1.grid_columnconfigure(5, weight=1)
28
29# Create Menu
30menubar = tk.Menu(root)
31
32# FileMenu
33filemenu = tk.Menu(menubar, tearoff=0)
34menubar.add_cascade(label='File', menu=filemenu)
35# filemenu.add_command(label='Import', command=lambda : changePage(frame1))
36filemenu.add_command(label='Import')
37filemenu.add_command(label='Export Data')
38filemenu.add_separator()
39# close button ok
40filemenu.add_command(label='Quit Application', command=lambda: root.destroy())
41
42# HelpMenu
43helpmenu = tk.Menu(menubar, tearoff=0)
44menubar.add_cascade(label='Help', menu=helpmenu)
45helpmenu.add_command(label='About Application')
46helpmenu.add_command(label='Developer Information')
47
48# Display Menu
49root.config(menu=menubar)
50
51
52label_name = tk.Label(frame1, text="Name", font=('', 10, "bold"))
53label_name.grid(row=0, column=0)
54
55entry_name = tk.Entry(frame1)
56entry_name.grid(row=0, column=1, sticky=(tk.W, tk.E))
57
58label_country = tk.Label(frame1, text="Country", font=('', 10, "bold"))
59label_country.grid(row=0, column=2)
60
61entry_country = tk.Entry(frame1)
62entry_country.grid(row=0, column=3, columnspan=2, sticky=(tk.W, tk.E))
63
64label_passport = tk.Label(frame1, text="Passport", font=('', 10, "bold"))
65label_passport.grid(row=1, column=0)
66
67entry_passport = tk.Entry(frame1)
68entry_passport.grid(row=1, column=1, sticky=(tk.W, tk.E))
69
70label_gender = tk.Label(frame1, text="Gender", font=('', 10, "bold"))
71label_gender.grid(row=1, column=2)
72var = tk.IntVar()
73tk.Radiobutton(frame1, text="Male", variable=var, value=1).grid(row=1, column=3)
74tk.Radiobutton(frame1, text="Female", variable=var, value=2).grid(row=1, column=4)
75
76label_from = tk.Label(frame1, text="From", font=('', 10, "bold"))
77label_from.grid(row=2, column=0)
78
79entry_from_start = tk.Entry(frame1)
80entry_from_start.grid(row=2, column=1, sticky=(tk.W, tk.E))
81
82label_to = tk.Label(frame1, text="to", font=('', 10, "bold"))
83label_to.grid(row=2, column=2)
84
85entry_to_end = tk.Entry(frame1)
86entry_to_end.grid(row=2, column=3, columnspan=2, sticky=(tk.W, tk.E))
87
88label_accomondation_type = tk.Label(frame1, text="Accomondation Type", font=('', 10, "bold"))
89label_accomondation_type.grid(row=3, column=0)
90
91menu_accom = tk.OptionMenu(frame1, 'Accomondations', 'Male Dorm', 'Female Form', 'Doble Room', 'Single Room')
92menu_accom.config(width=20)
93menu_accom.grid(row=3, column=1, sticky=(tk.W, tk.E))
94
95btn_book = tk.Button(frame1, text='Book Now', width=10)
96btn_book.grid(row=4, column=4, sticky=tk.E)
97
98btn_search = tk.Button(frame1, text='Search Entry', width=10)
99btn_search.grid(row=5, column=4, sticky=tk.E)
100
101btn_update = tk.Button(frame1, text='Update Entry', width=10)
102btn_update.grid(row=6, column=4, sticky=tk.E)
103
104btn_all = tk.Button(frame1, text='View All Entry', width=10)
105btn_all.grid(row=7, column=4, sticky=tk.E)
106
107btn_delete = tk.Button(frame1, text='Delete Selected Entry', width=10)
108btn_delete.grid(row=8, column=4, sticky=tk.E)
109
110btn_quit = tk.Button(frame1, text='Quit Application', width=10,command=lambda: root.destroy())
111btn_quit.grid(row=9, column=4, sticky=tk.E)
112
113
114
115# Title Label
116ttk.Label(root,
117 text = "ScrolledText Widget Example",
118 font = ("Times New Roman", 15),
119 background = 'green',
120 foreground = "white").grid(column = 0,
121 row = 0)
122
123# Creating scrolled text
124# area widget
125text_area = scrolledtext.ScrolledText(root,
126 wrap = tk.WORD,
127 width = 40,
128 height = 10,
129 font = ("Times New Roman",
130 15))
131
132text_area.grid(column = 0, pady = 10, padx = 10)
133
134# Placing cursor in the text area
135text_area.focus()
136
137# ウィンドウ表示
138root.mainloop()
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2020/10/31 12:13
退会済みユーザー
2020/10/31 12:20
退会済みユーザー
2020/10/31 12:22 編集
退会済みユーザー
2020/10/31 12:22
2020/10/31 12:26
2020/10/31 12:33 編集
2020/10/31 12:33
退会済みユーザー
2020/10/31 12:43