1
1
from tkinter import *
2
2
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 *
3
8
4
9
import fb
5
10
import threading
@@ -8,62 +13,81 @@ class FacebookApp(Frame):
8
13
def __init__ (self , parent ):
9
14
Frame .__init__ (self , parent )
10
15
self .parent = parent
16
+ self .parent .title ("Facebook 自動行銷軟體" )
17
+ self .pack (fill = BOTH , expand = 1 )
11
18
self .initUI ()
12
19
13
20
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
+
16
25
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 )
18
32
self .create_fbapp_login_frame (login_frame )
19
33
login_frame .pack (fill = X , pady = 10 )
20
34
21
- setting_frame = Frame (self )
35
+ setting_frame = Frame (parent_frame )
22
36
self .create_fbapp_setting_frame (setting_frame )
23
37
setting_frame .pack (fill = X , pady = 20 )
24
38
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 )
25
52
26
- # self.OutputText = Text(self, width = 35, height = 20, wrap = WORD)
27
- # self.OutputText.grid(row = 6, column = 0, columnspan = 4, sticky = S)
28
-
29
53
def create_fbapp_login_frame (self , parnet_frame ):
30
54
Label (parnet_frame , text = "電子郵件或電話 : " ).grid (row = 0 , sticky = E )
31
55
Label (parnet_frame , text = "密碼 : " ).grid (row = 1 , sticky = E )
32
56
33
- self .UserName = Entry (parnet_frame )
57
+ self .UserName = Entry (parnet_frame , bd = 3 )
34
58
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 )
36
60
self .PassWord .grid (row = 1 , column = 1 , sticky = E )
37
61
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 )
39
63
self .quitBtn = Button (parnet_frame , text = "離開" , command = self .application_quit ).grid (row = 0 , rowspan = 2 , column = 3 , sticky = NS )
40
64
41
65
def create_fbapp_setting_frame (self , parnet_frame ):
42
66
f1 = Frame (parnet_frame )
43
67
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 )
45
69
self .each_article_delay_min .pack (side = LEFT )
46
70
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 )
48
72
self .each_article_delay_max .pack (side = LEFT )
49
73
f1 .pack (fill = X )
50
74
51
75
f2 = Frame (parnet_frame )
52
76
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 )
54
78
self .how_many_article_should_pause .pack (side = LEFT )
55
79
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 )
57
81
self .fbapp_pause_sec_min .pack (side = LEFT )
58
82
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 )
60
84
self .fbapp_pause_sec_max .pack (side = LEFT )
61
85
Label (f2 , text = "秒" ).pack (side = LEFT )
62
86
f2 .pack (fill = X )
63
87
64
88
f3 = Frame (parnet_frame )
65
89
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 )
67
91
self .max_collect_groups .pack (side = LEFT )
68
92
f3 .pack (fill = X )
69
93
@@ -72,7 +96,20 @@ def create_fbapp_setting_frame(self, parnet_frame):
72
96
Checkbutton (f4 , text = "發完文是否要留言" , variable = self .check_comment_after_post , anchor = W ).grid (row = 3 , sticky = E )
73
97
f4 .pack (fill = X )
74
98
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 ):
76
113
username = self .UserName .get ()
77
114
password = self .PassWord .get ()
78
115
article_delay_min = self .each_article_delay_min .get ()
@@ -83,18 +120,17 @@ def login_facebook(self):
83
120
fb_max_groups_count = self .max_collect_groups .get ()
84
121
is_comment = self .check_comment_after_post .get ()
85
122
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
97
126
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
+
98
134
99
135
100
136
# self.th = threading.Thread(target = self.facebook_auto)
@@ -111,6 +147,6 @@ def facebook_auto(self):
111
147
112
148
root = Tk ()
113
149
# root.geometry("250x150+300+300")
114
- root .geometry ("500x500 " )
150
+ root .geometry ("800x500 " )
115
151
app = FacebookApp (root )
116
152
root .mainloop ()
0 commit comments