def build(self, **kwargs): Window.clearcolor = (1, 1, 1, 1) self.title = "Xfinity Wifi Connector" self.icon = "imgs/appIcon.png" layout = FloatLayout() # super(LoginScreen, self).__init__(**kwargs) layout.add_widget(MyLabel(text='Adapters: ', pos_hint={'x':x, 'y':y})) #Create adapters button adapterDropDown = DropDown(max_height=300,do_scroll_x=True) adapterButton = Button(text='Choose Adapter', size_hint=(buttonWidth,.05),pos_hint={'x':x+xAdd, 'y':y}) for adapter in adapters: btn = Button(text=adapter.hardwareName, size_hint_y=None, height=44) btnMap[btn]=adapter scaleButton(btn) btn.bind(on_release=lambda btn: adapterDropDown.select([btn,adapterButton])) # Add the button inside the dropdown adapterDropDown.add_widget(btn) adapterButton.bind(on_release=adapterDropDown.open) # Listen for the selection in the dropdown list and adapterDropDown.bind(on_select=onSelectInterface) downArrow = Image(source='imgs/down-arrow2.png',pos_hint={'x':x+xAdd+buttonWidth-.04, 'y':y},size_hint=(.05,.05)) # adapterButton.add_widget(downArrow) layout.add_widget(adapterButton) layout.add_widget(downArrow) # Networks button layout.add_widget(MyLabel(text='Networks: ', pos_hint={'x':x, 'y':y+yAdd})) networkButton.bind(on_release=networks.open) networks.bind(on_select=onSelectNetwork) downArrow = Image(source='imgs/down-arrow2.png',pos_hint={'x':x+xAdd+buttonWidth-.04, 'y':y+yAdd},size_hint=(.05,.05)) layout.add_widget(networkButton) layout.add_widget(downArrow) layout.add_widget(MyLabel(text='Refresh Rate: ', pos_hint={'x':x, 'y':y+yAdd*2})) timeLabel = MyLabel(text='57 mins', pos_hint={'x':x+xAdd+buttonWidth, 'y':y+yAdd*2}) st = Slider(min=10, max=70, value=57, size_hint=(buttonWidth,.05),pos_hint={'x':x+xAdd, 'y':y+yAdd*2},step=1) def OnSliderValueChange(instance,value): timeLabel.text = str(value)+" mins" st.bind(value=OnSliderValueChange) layout.add_widget(timeLabel) layout.add_widget(st) l = MyLabel(text='Time Till Next Refresh:', pos_hint={'x':x, 'y':y+yAdd*3}) layout.add_widget(l) l = MyLabel(text = "00:00:00",pos_hint={'x':x+xAdd+.045, 'y':y+yAdd*4.25},font_size='25sp',size_hint=(buttonWidth,.05)) refreshCountDown= SimpleCountDownTimer(l,10*60) layout.add_widget(l) l = MyLabel(text='Time On Connection:', pos_hint={'x':x, 'y':y+yAdd*5}) layout.add_widget(l) l = MyLabel(text = "00:00:00",pos_hint={'x':x+xAdd+.045, 'y':y+yAdd*6.20},font_size='25sp',size_hint=(buttonWidth,.05)) connectionTimer = SimpleCountUpTimer(l) layout.add_widget(l) img = Image(source='imgs/tex.png',pos_hint={'x':x+xAdd*3.5, 'y':y-.57}, size_hint=(.65,.65), allow_stretch=True) layout.add_widget(img) # commandStream = ScrollView() programOutput.update_status("Waiting to be turned on!") programOutput.update_status("Please pick adapter and network!") layout.add_widget(programOutput) #add xfinity logo pos_hint={'x':x+xAdd*4.5, 'y':y-.5},size_hint=(.45,.4),color = (1,0,0,1),valign="middle",font_size='15sp' xfinityImage = Image(source='imgs/xfinity-logo.png',pos_hint={'x':x+xAdd*5.5, 'y':y-.8},size_hint=(.25,.25)) layout.add_widget(xfinityImage) global isInternet def holdValue(instance, value): global isInternet if(not isInternet): instance.state = 'normal' else: instance.state = 'down' internet_connected = ToggleButton(text = 'Status: Internet Connected', state='normal',pos_hint={'x':x+xAdd*5, 'y':y-.825},size_hint=(.35,.07), color = (0,1,0,1),font_size='20sp') global isInternet isInternet = is_internet() if(isInternet): internet_connected.state = 'down' internet_connected.text = 'Status: Internet Connected' internet_connected.color = (0,1,0,1) else: internet_connected.state = 'normal' internet_connected.text = 'Status: No Internet' internet_connected.color = (1,0,0,1) internet_connected.bind(state=holdValue) layout.add_widget(internet_connected) global isOn switch = ToggleButton(text = 'Off', state='normal', pos_hint={'x':x+buttonWidth*.35, 'y':y+yAdd*8},size_hint=(.25,.1), color = (1,0,0,1)) threadSafeList = MyList() #Updates from network reset thread global thState thState = None def cb(dt): global lasttimeZ global countertimeZ global isInternet global thState if isOn: connectionTimer.update() refreshCountDown.update() if refreshCountDown.left() < 0 and( thState==None or not thState.locked()): thState =callback(switch, 'down', True) while len(threadSafeList) > 0: programOutput.update_status(threadSafeList.pop()) countertimeZ += dt # Update Internet Label if(countertimeZ > lasttimeZ + 20.0): print "Tick tock" # global isInternet isInternet = is_internet() if(isInternet): internet_connected.state = 'down' internet_connected.text = 'Status: Internet Connected' internet_connected.color = (0,1,0,1) else: internet_connected.state = 'normal' internet_connected.text = 'Status: No Internet' internet_connected.color = (1,0,0,1) lasttimeZ = countertimeZ Clock.schedule_interval(cb, .5) #create worker thread (resets connection) #create thread safe list # On/Off Button def callback(instance, value,auto=False): global isOn if(adapterSelected is not None and networkSelected is not None): if(value == 'down'): instance.text="On" instance.color=(0,1,0,1) programOutput.update_status("") programOutput.update_status("Network resetting") resetNetwork(adapterSelected,networkSelected,threadSafeList) refreshCountDown.setTimeLeft(st.value*60) connectionTimer.reset() isOn = True else: instance.text = "Off" instance.color=(1,0,0,1) isOn = False programOutput.update_status("Stopping timers! Network will not be automatically reset") elif value == 'down': programOutput.update_status("Please select adapter and corresponding network!") instance.state = 'normal' switch.bind(state=callback) layout.add_widget(switch) s = Screen(name='Xfinity Wifi Connector') s.add_widget(layout) sm = ScreenManager() sm.add_widget(s) return sm