Skip to content

Commit

Permalink
fix connect/disconnect button
Browse files Browse the repository at this point in the history
  • Loading branch information
p-eli committed Oct 9, 2015
1 parent 9bd37da commit fe8863c
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 15 deletions.
Binary file removed createApGui/__pycache__/__init__.cpython-35.pyc
Binary file not shown.
Binary file removed createApGui/__pycache__/createEditAp.cpython-35.pyc
Binary file not shown.
Binary file removed createApGui/__pycache__/gui.cpython-35.pyc
Binary file not shown.
Binary file removed createApGui/__pycache__/language.cpython-35.pyc
Binary file not shown.
Binary file removed createApGui/__pycache__/runningAp.cpython-35.pyc
Binary file not shown.
Binary file not shown.
Binary file removed createApGui/__pycache__/trayIcon.cpython-35.pyc
Binary file not shown.
Binary file not shown.
Binary file removed createApGui/__pycache__/userSetting.cpython-35.pyc
Binary file not shown.
41 changes: 31 additions & 10 deletions createApGui/createEditAp.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def __init__(self, setting):

def show(self, page=None):
self.show_all()
self.updateStatusPage()
if page != None:
Gtk.Notebook.do_change_current_page(self.notebook,page-self.notebook.get_current_page())

Expand Down Expand Up @@ -75,9 +76,17 @@ def initStatusPage(self):
self.statusTotalSending = Gtk.Label()
self.createLabel(self._('None'), [2,3,7,8], table, self.statusTotalSending, aligment='left')
#connect / disconect button
self.connectDisconectButton = Gtk.Button()
self.createButton(self._('Connect'),[2,3,9,10],table,self.connectDisconnect,self.connectDisconectButton )
self.updateStatusPage()
self.errorButton = Gtk.Button()
self.createButton(self._('Error details'),[2,3,9,10],table,self.connectDisconnect,self.errorButton)
#connect / disconect button
self.connectButton = Gtk.Button()
self.createButton(self._('Connect'),[2,3,9,10],table,self.connectDisconnect,self.connectButton)
#connect / disconect button
self.disconnectButton = Gtk.Button()
self.createButton(self._('Disconnect'),[2,3,9,10],table,self.connectDisconnect,self.disconnectButton)

#self.updateStatusPage()

self.notebook.append_page(table, Gtk.Label(self._('Running AP')))

def connectDisconnect(self, button=None):
Expand Down Expand Up @@ -135,7 +144,7 @@ def initEditPage(self):
table.set_border_width(10)
table.set_row_spacings(10)
table.set_col_spacings(10)
self.store = Gtk.ListStore(str, str, str)
self.store = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING)
self.setting['userSetting'].getApStore(self.store)
self.treeview = Gtk.TreeView(model=self.store)
self.createTextViewColumn([self._('AP name'),self._('Interface1'),self._('Interface2')])
Expand Down Expand Up @@ -207,10 +216,11 @@ def initAboutPage(self):
self.notebook.append_page(table, Gtk.Label(self._('About')))

def createButton(self, text, pos, table, action, button=None):
if button == None:
button = Gtk.Button.new_with_mnemonic(text)
else:
button.set_label(text)
if text != None:
if button == None:
button = Gtk.Button.new_with_mnemonic(text)
else:
button.set_label(text)
button.connect("clicked", action)
table.attach(button,pos[0],pos[1],pos[2],pos[3])

Expand Down Expand Up @@ -305,7 +315,7 @@ def createAP(self, button=None, createAp=None):
Gtk.Notebook.do_change_current_page(self.notebook,-self.notebook.get_current_page())

def updateStatusPage(self, signal=None):
if self.statusTitleLabel.get_text() != self.setting['runningAp'].status['text']:
# if self.statusTitleLabel.get_text() != self.setting['runningAp'].status['text']:
self.statusTitleLabel.set_text(self.setting['runningAp'].status['text'])
self.statusNameAp.set_text(self.setting['runningAp'].activeAp['name'])
self.statusInterface1.set_text(self.setting['runningAp'].activeAp['interface1'])
Expand All @@ -314,7 +324,18 @@ def updateStatusPage(self, signal=None):
self.statusTotalReciving.set_text('None')
self.statusSending.set_text('None')
self.statusTotalSending.set_text('None')
self.connectDisconectButton.set_label(self.setting['runningAp'].status['button'])
if self.setting['runningAp'].status['active']:
self.disconnectButton.show()
self.connectButton.hide()
self.errorButton.hide()
elif self.setting['runningAp'].errorMsg['newMsg']:
self.disconnectButton.hide()
self.connectButton.hide()
self.errorButton.show()
else:
self.disconnectButton.hide()
self.connectButton.show()
self.errorButton.hide()


def saveCreateAction(self, button=None):
Expand Down
3 changes: 1 addition & 2 deletions createApGui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ def firstStart(self):
self.start()

def start(self):

tray = TrayIcon(self.setting)
self.tray = TrayIcon(self.setting)
Gtk.main()

def getPath(self):
Expand Down
8 changes: 5 additions & 3 deletions createApGui/runningAp.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def stopAp(self):
self.interfaceThread.stop()
self.stopStatistic()
self.reInit()
# self.updatingStatus()

def newCmdMsg(self, signal=None):
self.interfaceLock.acquire()
Expand All @@ -76,9 +77,9 @@ def newCmdMsg(self, signal=None):
self.__status['text'] = self._('INTERFACE-DISABLED')
# elif 'AP-DISABLED' in msg or 'done' in msg:
# self.reInit()
# else:
# self.lock.release()
# return
# else:
# self.interfaceLock.release()
# return

self.interfaceLock.release()
self.updatingStatus()
Expand Down Expand Up @@ -120,6 +121,7 @@ def stopStatistic(self):
self.statisticThread.stop()

def updatingStatus(self):
print('update status jebat')
if self.updatingPage['statusWindow']:
self.updatingPage['statusWindow']()
elif self.updatingPage['tray']:
Expand Down

0 comments on commit fe8863c

Please sign in to comment.