Skip to content

Commit f735922

Browse files
author
tittanlee
committedMar 3, 2016
1. App frame separate two part, right and left.
2. Left frame is setting page. 3. Right frame is group list frame.
1 parent 7285638 commit f735922

File tree

1 file changed

+65
-29
lines changed

1 file changed

+65
-29
lines changed
 

‎fbapp.py

+65-29
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
from tkinter import *
22
from tkinter import messagebox
3+
from tkinter import filedialog
4+
from tkinter.scrolledtext import ScrolledText
5+
from tkinter.ttk import *
6+
7+
from statusbar import *
38

49
import fb
510
import threading
@@ -8,62 +13,81 @@ class FacebookApp(Frame):
813
def __init__(self, parent):
914
Frame.__init__(self, parent)
1015
self.parent = parent
16+
self.parent.title("Facebook 自動行銷軟體")
17+
self.pack(fill=BOTH, expand=1)
1118
self.initUI()
1219

1320
def initUI(self):
14-
self.parent.title("Facebook 自動行銷軟體")
15-
self.pack(fill=BOTH, expand=1)
21+
left_frame = Frame(self)
22+
self.create_left_frame_ui(left_frame)
23+
left_frame.pack(fill = BOTH, expand = 1, side = LEFT)
24+
1625

17-
login_frame = Frame(self)
26+
right_frame = Frame(self)
27+
self.create_right_frame_ui(right_frame)
28+
right_frame.pack(fill = BOTH, expand = 1, side = LEFT)
29+
30+
def create_left_frame_ui(self, parent_frame):
31+
login_frame = Frame(parent_frame)
1832
self.create_fbapp_login_frame(login_frame)
1933
login_frame.pack(fill = X, pady = 10)
2034

21-
setting_frame = Frame(self)
35+
setting_frame = Frame(parent_frame)
2236
self.create_fbapp_setting_frame(setting_frame)
2337
setting_frame.pack(fill = X, pady = 20)
2438

39+
self.textPad = ScrolledText(parent_frame, pady = 30, width = 70, height = 10, bg = "gray", bd = 3)
40+
self.textPad.pack(fill = X)
41+
42+
self.status_bar = StatusBar(parent_frame)
43+
self.status_bar.pack(side=BOTTOM, fill=X)
44+
45+
46+
def create_right_frame_ui(self, parent_frame):
47+
listbox = Listbox(parent_frame, width = 30, height = 40, bd = 3)
48+
listbox.pack()
49+
listbox.insert(END, "a list entry")
50+
for item in ["one", "two", "three", "four"]:
51+
listbox.insert(END, item)
2552

26-
# self.OutputText = Text(self, width = 35, height = 20, wrap = WORD)
27-
# self.OutputText.grid(row = 6, column = 0, columnspan = 4, sticky = S)
28-
2953
def create_fbapp_login_frame(self, parnet_frame):
3054
Label(parnet_frame, text="電子郵件或電話 : ").grid(row= 0, sticky=E)
3155
Label(parnet_frame, text="密碼 : ").grid(row = 1, sticky=E)
3256

33-
self.UserName = Entry(parnet_frame)
57+
self.UserName = Entry(parnet_frame, bd = 3 )
3458
self.UserName.grid(row = 0, column = 1, sticky=E)
35-
self.PassWord = Entry(parnet_frame, show = "*")
59+
self.PassWord = Entry(parnet_frame, show = "*", bd = 3 )
3660
self.PassWord.grid(row = 1, column = 1, sticky=E)
3761

38-
self.StartBtn = Button(parnet_frame, text="開始", command = self.login_facebook).grid(row = 0, rowspan = 2, column = 2, sticky = NS)
62+
self.StartBtn = Button(parnet_frame, text="開始", command = self.application_start).grid(row = 0, rowspan = 2, column = 2, sticky = NS)
3963
self.quitBtn = Button(parnet_frame, text="離開", command = self.application_quit).grid(row = 0, rowspan = 2, column = 3, sticky = NS)
4064

4165
def create_fbapp_setting_frame(self, parnet_frame):
4266
f1 = Frame(parnet_frame)
4367
Label(f1, text="每一篇文章間隔(秒)").pack(side = LEFT)
44-
self.each_article_delay_min = Entry(f1, width = 5)
68+
self.each_article_delay_min = Entry(f1, width = 5, bd = 3 )
4569
self.each_article_delay_min.pack(side = LEFT)
4670
Label(f1, text=" ~ ").pack(side = LEFT)
47-
self.each_article_delay_max = Entry(f1, width = 5)
71+
self.each_article_delay_max = Entry(f1, width = 5, bd = 3 )
4872
self.each_article_delay_max.pack(side = LEFT)
4973
f1.pack(fill = X)
5074

5175
f2 = Frame(parnet_frame)
5276
Label(f2, text="每發").pack(side = LEFT)
53-
self.how_many_article_should_pause = Entry(f2, width = 5)
77+
self.how_many_article_should_pause = Entry(f2, width = 5, bd = 3 )
5478
self.how_many_article_should_pause.pack(side = LEFT)
5579
Label(f2, text="篇文章,休息").pack(side = LEFT)
56-
self.fbapp_pause_sec_min = Entry(f2, width = 5)
80+
self.fbapp_pause_sec_min = Entry(f2, width = 5, bd = 3 )
5781
self.fbapp_pause_sec_min.pack(side = LEFT)
5882
Label(f2, text = " ~ ").pack(side = LEFT)
59-
self.fbapp_pause_sec_max = Entry(f2, width = 5)
83+
self.fbapp_pause_sec_max = Entry(f2, width = 5, bd = 3 )
6084
self.fbapp_pause_sec_max.pack(side = LEFT)
6185
Label(f2, text = "秒").pack(side = LEFT)
6286
f2.pack(fill = X)
6387

6488
f3 = Frame(parnet_frame)
6589
Label(f3, text = "搜集社團最大數量:").pack(side = LEFT)
66-
self.max_collect_groups = Entry(f3, width = 5)
90+
self.max_collect_groups = Entry(f3, width = 5, bd = 3 )
6791
self.max_collect_groups.pack(side = LEFT)
6892
f3.pack(fill = X)
6993

@@ -72,7 +96,20 @@ def create_fbapp_setting_frame(self, parnet_frame):
7296
Checkbutton(f4, text="發完文是否要留言", variable=self.check_comment_after_post, anchor = W).grid(row = 3, sticky=E)
7397
f4.pack(fill = X)
7498

75-
def login_facebook(self):
99+
f5 = Frame(parnet_frame)
100+
self.browse_button = Button(f5, text="開啟文案目錄", command=self.browse_file_directory, width=10)
101+
self.browse_button.pack(side = LEFT)
102+
self.dir_name = StringVar()
103+
self.browse_dir_name = Entry(f5, width = 40, bd = 3 , textvariable = self.dir_name)
104+
self.browse_dir_name.pack(side = LEFT)
105+
f5.pack(fill = X)
106+
107+
108+
def browse_file_directory(self):
109+
directory_name= filedialog.askdirectory()
110+
self.dir_name.set(directory_name)
111+
112+
def application_start(self):
76113
username = self.UserName.get()
77114
password = self.PassWord.get()
78115
article_delay_min = self.each_article_delay_min.get()
@@ -83,18 +120,17 @@ def login_facebook(self):
83120
fb_max_groups_count = self.max_collect_groups.get()
84121
is_comment = self.check_comment_after_post.get()
85122

86-
if(username == "") or (password == ""):
87-
messagebox.showwarning("錯誤", "請輸入帳號及密碼")
88-
return
89-
90-
if not ((article_delay_min.isdigit()) or (article_delay_max.isdigit()) or
91-
(article_count_delay.isdigit()) or
92-
(app_pause_min.isdigit()) or (app_pause_max.isdigit()) or
93-
(fb_max_groups_count.isdigit())):
94-
messagebox.showwarning("錯誤", "請輸入正確的數值")
95-
return
96-
123+
# if(username == "") or (password == ""):
124+
# messagebox.showwarning("錯誤", "請輸入帳號及密碼")
125+
# return
97126

127+
# if not ((article_delay_min.isdigit()) and (article_delay_max.isdigit()) and
128+
# (article_count_delay.isdigit()) and
129+
# (app_pause_min.isdigit()) and (app_pause_max.isdigit()) and
130+
# (fb_max_groups_count.isdigit())):
131+
# messagebox.showwarning("錯誤", "請輸入正確的數值")
132+
# return
133+
98134

99135

100136
# self.th = threading.Thread(target = self.facebook_auto)
@@ -111,6 +147,6 @@ def facebook_auto(self):
111147

112148
root = Tk()
113149
# root.geometry("250x150+300+300")
114-
root.geometry("500x500")
150+
root.geometry("800x500")
115151
app = FacebookApp(root)
116152
root.mainloop()

0 commit comments

Comments
 (0)
Please sign in to comment.