def get_name(self): hciconfig = ProcessInterface("hciconfig hci0 name") while not hciconfig.process_finished(): time.sleep(0.1) ## wait for command to compute output = hciconfig.read_from_process() if output.find("Name:") >= 0: return output.split("Name:")[1].split("'")[1] return "down"
def get_ip_address(self): if len(self.address) <= 0: return "none" else: ## todo mind more than one device ifconfig = ProcessInterface("ifconfig bnep0") time.sleep(1) ## wait for command to compute output = ifconfig.read_from_process() # print "output of get_ip_address: [%s]" % output if len(output.split("inet addr:")) > 1: return output.split("inet addr:")[1].split(" ")[0].strip()
def update_list(self, event): self.hcitool = ProcessInterface("%s scan" % HCITOOL_CMD) self.list_store1.clear() self.hcitool.register_event_handler(":", self.add_scan_list_entry) pand_list_tool = ProcessInterface("pand -l") time.sleep(1) ## wait for command to compute output = pand_list_tool.read_from_process() self.connected_peers = [] for line in output.split("\n"): if len(line.split(" ")) > 1: self.connected_peers.append(line.split(" ")[1])
def get_address(self): hciconfig = ProcessInterface("%s %s" % (HCICONFIG_CMD, BLUETOOTH_DEVICE)) time.sleep(1) ## wait for command to compute output = hciconfig.read_from_process() # print "output of get_address: [%s]" % output # hciconfig.close_process() ## has no effect anyway :-( TODO - fix if output.find("BD Address: "): if len(output.split("BD Address: ")) > 1 and \ len(output.split("BD Address: ")[1].split(" ")) > 1: self.address = output.split("BD Address: ")[1].split(" ")[0] return output.split("BD Address: ")[1].split(" ")[0] else: return "offline" return "unknown"
def update_list(self): ## exec hcitool scan hcitool = ProcessInterface("%s scan hci0" % HCITOOL_CMD) while not hcitool.process_finished(): time.sleep(0.1) ## wait for command to compute hcitool_output = hcitool.read_from_process() ## exec pand list pand = ProcessInterface("pand -l") while not pand.process_finished(): time.sleep(0.1) ## wait for command to compute pand_output = pand.read_from_process() ## filter output for visible peers visible_peers = [] for line in hcitool_output.split("\n"): if line.find(":") >= 1: visible_peers.append((line.strip().split("\t")[1],\ line.strip().split("\t")[0])) ## filter output for connected peers connected_peers = [] for line in pand_output.split("\n"): if len(line.split(" ")) > 1: connected_peers.append(line.split(" ")[1]) return (visible_peers, connected_peers)
def start_gsm_tool(self): if os.path.exists(LIBGSM_TOOL): self.gsm_tool_at = ProcessInterface( "%s -m atcmd" % LIBGSM_TOOL) time.sleep(0.2) error_out = self.gsm_tool_at.read_error_from_process() if len(error_out) > 0: error_out = error_out.rstrip('\n').lstrip('\n').rstrip( '\r').lstrip('\r') self.update_state("error libgsm-tool: %s" % error_out) print "error libgsm-tool: %s" % error_out self.state_changed("Off") return False self.gsm_tool_at.register_event_handler("RSTR=",\ self.at_state_changed) time.sleep(0.3) ## request regestration state self.gsm_tool_at.write_to_process("AT+CREG?") self.gsm_tool_at.register_event_handler("EVENT: Signal Quality",\ self.link_quality_changed) self.gsm_tool_at.register_event_handler("EVENT: Netreg registered",\ self.network_registration_changed) self.gsm_tool_at.register_event_handler("EVENT: Signal Quality",\ self.link_quality_changed) self.gsm_tool_at.register_event_handler("# Power-On",\ self.state_changed) self.gsm_tool_at.register_event_handler("# Register",\ self.state_changed) self.gsm_tool_at.register_event_handler("", self.update_output) self.gsm_tool_at.register_event_handler("Our current operator is",\ self.operator_changed) self.gsm_tool_at.register_event_handler("ERROR reading from gsm_fd",\ self.gsm_fs_changed) self.state_changed("Init") return True else: self.update_state("%s not found, most functions in the GSM panel disabled" % LIBGSM_TOOL) self.gsm_tool_at = False return False
class BluetoothPanel(gtk.VBox): """ Settings for the Bluetooth Module of GTA01 """ def __init__(self): gtk.VBox.__init__(self, False, 0) self.address = "" self.scan_for_bt_peers = True self.create_notebook_page() def create_notebook_page(self): self.set_border_width(0) ## Power State of Bluetooth Module cell_frame = gtk.Frame("Bluetooth State") upper_box = gtk.HBox() upper_box.set_border_width(15) # power self.power_state_cbtn = gtk.CheckButton("Powered") self.power_state_cbtn.set_sensitive(1) self.power_state_cbtn.connect('pressed', \ lambda *w: self.power_state_cbtn.set_inconsistent(1)) self.power_state_cbtn.connect('released', self.toggle_power) upper_box.pack_start(self.power_state_cbtn, True, True, 0) # discoverability self.visible_state_cbtn = gtk.CheckButton("Visible") self.visible_state_cbtn.set_sensitive(1) #self.visible_state_cbtn.connect('pressed', \ # lambda *w: self.visible_state_cbtn.set_inconsistent(1)) self.visible_state_cbtn.connect('released', \ lambda *w: self.visible_state_cbtn.set_active(1)) upper_box.pack_start(self.visible_state_cbtn, True, True, 0) # pand self.pand_state_cbtn = gtk.CheckButton("Allow PAN") self.pand_state_cbtn.set_sensitive(1) self.pand_state_cbtn.connect('pressed', \ lambda *w: self.pand_state_cbtn.set_inconsistent(1)) self.pand_state_cbtn.connect('released', self.toggle_listen_pand) upper_box.pack_start(self.pand_state_cbtn, True, True, 0) cell_frame.add(upper_box) self.pack_start(cell_frame, False, False, 0) ## Info on BT state info_frame = gtk.Frame("Bluetooth Informations") info_box = gtk.VBox() info_box.set_border_width(15) self.address_label = gtk.Label("Bluetooth Address: %s" % self.get_address()) self.ip_address_label = gtk.Label("IP Address: %s" % self.get_ip_address()) info_box.add(self.address_label) info_box.add(self.ip_address_label) info_frame.add(info_box) self.pack_start(info_frame, False, True, 1) scan_frame = gtk.Frame("Devices in range") scan_frame_box = gtk.VBox() scan_frame_box.set_border_width(15) (scroll_win, self.tree_view1, self.list_store1) = \ self.make_list_view(3, \ ["Name", "Address", "PAN Link"], \ ["text", "text", "toggle"]) scan_frame_box.pack_start(scroll_win, True, True, 0) # self.add_scan_list_entry self.list_store1.append(("Scanning for Peers", "", False)) self.update_infos() self.update_list(None) scan_btn_box = gtk.HBox() update_btn = gtk.Button("Update\nList") update_btn.connect('clicked', self.update_list) scan_btn_box.add(update_btn) connect_btn = gtk.Button("Connect\n(PAN)") connect_btn.connect('clicked', self.connect_to_peer) scan_btn_box.add(connect_btn) scan_frame_box.pack_start(scan_btn_box, False, True, 0) scan_frame.add(scan_frame_box) self.pack_start(scan_frame, True, True, 0) # settings powerstate as last operation to ensure existence of all # widgets if self.get_power_state(): self.power_state_cbtn.set_active(True) self.visible_state_cbtn.set_active(True) self.toggle_power(None) else: self.power_state_cbtn.set_active(False) self.visible_state_cbtn.set_active(False) ## finish notebook page creation self.show_all() ################################################################################ ######################### build GUI helper ##################################### ################################################################################ ## we allow one toggle -for fixed (text, text, toggle) def make_list_view(self, number, names, type = ["text", "text", "text"]): scroll_win = gtk.ScrolledWindow() scroll_win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) #try: if type.index("toggle") >= 0: list_store = gtk.ListStore(str, str, 'gboolean')#gobject.TYPE_BOOLEAN) #except: # list_store = gtk.ListStore(*(str,) * number) tree_view = gtk.TreeView(list_store) cell = gtk.CellRendererText() cell.set_property('editable', False) cell_toggle = gtk.CellRendererToggle() cell_toggle.set_property('activatable', True) tvcolumn = [] for i in range(number): if type[i] == "text": tvcolumn.append(gtk.TreeViewColumn(names[i], cell, markup=i)) if type[i] == "toggle": toggle_column = gtk.TreeViewColumn(names[i], cell_toggle) tvcolumn.append(toggle_column) toggle_column.add_attribute(cell_toggle, attribute = "active", \ column = 2) tree_view.append_column(tvcolumn[i]) tvcolumn[i].set_sort_column_id(i) tvcolumn[i].set_resizable(True) scroll_win.add(tree_view) return (scroll_win, tree_view, list_store) ################################################################################ ####################### Callbacks from GUI ##################################### ################################################################################ def toggle_power(self, event): print "Toggleing Power state!" if not self.get_power_state(): set_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER, 1) self.list_store1.append(("Scanning for Peers", "", False)) else: set_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER, 0) if self.power_state_cbtn.get_active() != self.get_power_state(): self.power_state_cbtn.get_active() ## have to wait for async init :-( - TODO - make updates async. time.sleep(2) self.update_infos() self.update_list(None) ## for now we are alyways visible when power is on self.visible_state_cbtn.set_active(self.get_power_state()) self.power_state_cbtn.set_inconsistent(0) def toggle_listen_pand(self, event): if self.pand_state_cbtn.get_active(): print "Starting pand [pand -s]" os.system("pand -s") else: print "pand already listening for connections" self.pand_state_cbtn.set_active(1) self.pand_state_cbtn.set_inconsistent(0) def get_power_state(self): state = get_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER)[0] print "Powerstate is [%s]" %state if state.isdigit(): return int(state) else: return 0 def connect_to_peer(self, event): def call_cmd(string): print("calling command [%s]" % string) os.system(string) ## get selected entry if len(self.address) <= 0: return (model, model_iter) = self.tree_view1.get_selection().get_selected() if model_iter >= 1: name = model.get_value(model_iter, 0) # column is first (name) addr = model.get_value(model_iter, 1) # column is second (adr) call_cmd("pand -c %s" % addr) ## convert last number of addr to decimal and user as last ip number call_cmd("ip a add 10.0.0.%s/24 dev bnep0" % \ int(self.address.split(":")[-1], 16)) ## set main ip of bnep0 (in case a different ip was set) call_cmd("ifconfig bnep0 10.0.0.%s" % \ int(self.address.split(":")[-1], 16)) ## set 10.0.0.1 to default GW - won't work if GW is set already call_cmd("ip r add default via 10.0.0.1") time.sleep(1) self.update_infos() def update_list(self, event): self.hcitool = ProcessInterface("%s scan" % HCITOOL_CMD) self.list_store1.clear() self.hcitool.register_event_handler(":", self.add_scan_list_entry) pand_list_tool = ProcessInterface("pand -l") time.sleep(1) ## wait for command to compute output = pand_list_tool.read_from_process() self.connected_peers = [] for line in output.split("\n"): if len(line.split(" ")) > 1: self.connected_peers.append(line.split(" ")[1]) ################################################################################ #################### subprocess callbacks (outputs) ############################ ################################################################################ def add_scan_list_entry(self, string): if string.find(":") >= 0: print ("new") try: self.connected_peers.index(string.strip().split("\t")[0]) found = True ## we've had no exception except: found = False print ("append: [%s,%s,%s]" % (string.strip().split("\t")[1], \ string.strip().split("\t")[0], found)) self.list_store1.append((string.strip().split("\t")[1], \ string.strip().split("\t")[0], found)) def ip_address_changed(self, string): # print "output of get_ip_address: [%s]" % string if len(string.split("inet addr:")) > 1: self.address_label.set_text("Bluetooth Address: %s" % \ string.split("inet addr:")[1].split(" ")[0].strip()) def bt_address_changed(self, string): # print "output of get_address: [%s]" % string if string.find("BD Address: "): if len(string.split("BD Address: ")) > 1 and \ len(string.split("BD Address: ")[1].split(" ")) > 1: self.address = string.split("BD Address: ")[1].split(" ")[0] self.ip_address_label.set_text("Address: %s" % \ string.split("BD Address: ")[1].split(" ")[0]) else: self.ip_address_label.set_text("Address: offline") self.ip_address_label.set_text("Address: unknown") ################################################################################ ####################### Interface to bluez tools ############################### ################################################################################ def update_infos(self): self.address_label.set_text("Bluetooth Address: %s" % self.get_address()) self.ip_address_label = gtk.Label("IP Address: %s" % self.get_ip_address()) def get_ip_address(self): if len(self.address) <= 0: return "none" else: ## todo mind more than one device ifconfig = ProcessInterface("ifconfig bnep0") time.sleep(1) ## wait for command to compute output = ifconfig.read_from_process() # print "output of get_ip_address: [%s]" % output if len(output.split("inet addr:")) > 1: return output.split("inet addr:")[1].split(" ")[0].strip() def get_address(self): hciconfig = ProcessInterface("%s %s" % (HCICONFIG_CMD, BLUETOOTH_DEVICE)) time.sleep(1) ## wait for command to compute output = hciconfig.read_from_process() # print "output of get_address: [%s]" % output # hciconfig.close_process() ## has no effect anyway :-( TODO - fix if output.find("BD Address: "): if len(output.split("BD Address: ")) > 1 and \ len(output.split("BD Address: ")[1].split(" ")) > 1: self.address = output.split("BD Address: ")[1].split(" ")[0] return output.split("BD Address: ")[1].split(" ")[0] else: return "offline" return "unknown" def get_features(self): """using the hciconfig tool to get the list of supported features"""
class GSMPanel(gtk.VBox): def __init__(self): gtk.VBox.__init__(self, False, 0) self.create_notebook_page() gtk.gdk.threads_init() self.gsm_state = 0 self.start_gsm_tool() def __del__(self): try: self.gsm_tool_at.write_to_process("\d") ## EOF! except: print "GSMPanel: Warning: gsmtool seems to be closed already" time.sleep(0.3) def start_gsm_tool(self): if os.path.exists(LIBGSM_TOOL): self.gsm_tool_at = ProcessInterface( "%s -m atcmd" % LIBGSM_TOOL) time.sleep(0.2) error_out = self.gsm_tool_at.read_error_from_process() if len(error_out) > 0: error_out = error_out.rstrip('\n').lstrip('\n').rstrip( '\r').lstrip('\r') self.update_state("error libgsm-tool: %s" % error_out) print "error libgsm-tool: %s" % error_out self.state_changed("Off") return False self.gsm_tool_at.register_event_handler("RSTR=",\ self.at_state_changed) time.sleep(0.3) ## request regestration state self.gsm_tool_at.write_to_process("AT+CREG?") self.gsm_tool_at.register_event_handler("EVENT: Signal Quality",\ self.link_quality_changed) self.gsm_tool_at.register_event_handler("EVENT: Netreg registered",\ self.network_registration_changed) self.gsm_tool_at.register_event_handler("EVENT: Signal Quality",\ self.link_quality_changed) self.gsm_tool_at.register_event_handler("# Power-On",\ self.state_changed) self.gsm_tool_at.register_event_handler("# Register",\ self.state_changed) self.gsm_tool_at.register_event_handler("", self.update_output) self.gsm_tool_at.register_event_handler("Our current operator is",\ self.operator_changed) self.gsm_tool_at.register_event_handler("ERROR reading from gsm_fd",\ self.gsm_fs_changed) self.state_changed("Init") return True else: self.update_state("%s not found, most functions in the GSM panel disabled" % LIBGSM_TOOL) self.gsm_tool_at = False return False ################################################################################ ######### Callbacks from libgsmd-tool subprocess output - as callbacks ######### ################################################################################ def update_gsmd_state(self): None def update_output(self, string): ## remove tailing and starting \n and \r - just in case string = string.rstrip('\n').lstrip('\n').rstrip('\r').lstrip('\r') print "libgsmd-tool: <%s>" % string self.update_state(string) self.update_gsmd_state() def gsm_fs_changed(self, string): self.state_changed("Off") ## called from gsmd at answer def at_state_changed(self, string): if string.find("RSTR=") < 0 or string.find(":") < 0\ or string.find("`") < 0: if string.find("OK") >= 0: if self.gsm_state == 1: self.state_changed("Power-On") time.sleep(1) self.gsm_tool_at.write_to_process("AT+COPS?") ## request oper. name time.sleep(1) self.gsm_tool_at.write_to_process("AT+CSQ") ## request sign. qual. else: return False return True response = string.split("`")[1].rstrip("'") cmd = response.split(":")[0] resp = response.split(":")[1].split(",") resp = [x.rstrip("\n").rstrip("'").rstrip("\"").lstrip("\"") for x in resp] print "got a response from modem: CMD: %s Response: %s" %(cmd, resp) ## set location area code and cellid if string.find("+CREG") >= 0: if len(resp) == 3: location_area = resp[1] cell_id = resp[2] if len(resp) >= 4: location_area = resp[2] cell_id = resp[3] if len(resp) >= 3: self.reg_state_cbtn.set_active(1) self.connected_state_cbtn.set_active(1) self.state_changed("Connected") else: location_area = "" cell_id = "" self.state_changed("Init") print "Got a location: %s/%s" % (location_area, cell_id) self.area_code_lbl.set_text("Location Area Code: %s" % location_area) self.cell_id_lbl.set_text("Cell ID: %s" % cell_id) if len(resp) >= 2: # it should always be if resp[0] == 0: self.reg_state_cbtn.set_active(0) self.connected_state_cbtn.set_active(0) if resp[1] == 0 or resp[1] == 2 or resp[1] == 3: self.connected_state_cbtn.set_active(0) if resp[1] == 5 or resp[1] == 1: self.reg_state_cbtn.set_active(1) self.connected_state_cbtn.set_active(1) if string.find("+COPS") >= 0: if len(resp) >= 3: self.operator_lbl.set_text("Operator: %s" % resp[2]) """ else: if len(resp) == 1: time.sleep(3) ## request oper. name self.gsm_tool_at.write_to_process("AT+COPS?") time.sleep(1) ## request sign. qual. self.gsm_tool_at.write_to_process("AT+CSQ") """ if string.find("+CSQ") >= 0: if len(resp) >= 2: self.link_quality_changed("%s %s %s %s" % \ (resp[0], resp[0], resp[0], resp[0], )) ## set opername - ToDo ## called from gsmd event def link_quality_changed(self, line): ## ToDo - strange - maybe filter the '#'??? try: quality = int(line.split(" ")[4]) except: quality = int(line.split(" ")[3]) if quality != 99: self.scale_adj.value = int((quality / MAX_SIGNAL) * 100) self.sig_stength_scale.set_text("%3.4s %%" % ((quality / MAX_SIGNAL) * 100)) ## called from gsmd event ## ToDo - remove strange string-list-join-thing def operator_changed(self, line): line_list = line.split(" ") operator = " ".join([line_list[x+4] for x in range(len(line_list)-4)]) self.operator_lbl.set_text("Operator: %s" % operator.rstrip('\n')) ## called from gsmd event ## requesting name of operator def network_registration_changed(self, line): if len(line.split()) >= 11: location_area = line.split()[7] cell_id = line.split()[10] else: location_area = "" cell_id = "" self.area_code_lbl.set_text("Location Area Code: %s"%location_area) self.cell_id_lbl.set_text("Cell ID: %s" % cell_id) if cell_id != "?": print "setting connected - cell_id=%s" % cell_id self.state_changed("Connected") self.operator_lbl.set_text("Operator: ") ## called from gsmd event def state_changed(self, line): self.gsm_state = 0 if line.find("Init") >= 0: self.gsm_state = 1 if line.find("Power-On") >= 0: self.gsm_state = 2 if line.find("Register") >= 0: self.gsm_state = 3 if line.find("Connected") >= 0: self.gsm_tool_at.write_to_process("AT+COPS?") ## request oper. name time.sleep(1) self.gsm_tool_at.write_to_process("AT+CSQ") ## request sign. qual. self.gsm_state = 4 ## may flicker self.lib_state_cbtn.set_active(0) self.power_state_cbtn.set_active(0) self.power_state_cbtn.set_sensitive(0) self.power_state_cbtn.set_inconsistent(0) self.reg_state_cbtn.set_active(0) self.reg_state_cbtn.set_sensitive(0) self.reg_state_cbtn.set_inconsistent(0) self.connected_state_cbtn.set_active(0) self.sig_stength_scale.set_text("Invalid") ## nothing if self.gsm_state == 0: self.start_gsmd_btn.set_sensitive(1) self.start_gsmd_btn.set_sensitive(1) self.stop_gsmd_btn.set_sensitive(0) ## init lib if self.gsm_state > 0: self.lib_state_cbtn.set_active(1) self.power_state_cbtn.set_sensitive(1) self.start_gsmd_btn.set_sensitive(0) self.stop_gsmd_btn.set_sensitive(1) ## power if self.gsm_state > 1: self.power_state_cbtn.set_active(1) self.reg_state_cbtn.set_sensitive(1) ## register if self.gsm_state > 2: self.reg_state_cbtn.set_active(1) ## connected if self.gsm_state > 3: self.connected_state_cbtn.set_active(1) ################################################################################ ############################## Callbacks from UI ############################### ################################################################################ def power_cb_changed(self, widget): widget.set_inconsistent(1) if widget.get_active(): ## power on modem print "sending power-on request to modem" self.gsm_tool_at.write_to_process("AT+CFUN=1") def register_cb_changed(self, widget): widget.set_inconsistent(1) if widget.get_active(): print "sending register request to modem" self.gsm_tool_at.write_to_process("AT+COPS=0") def stop_gsmd(self, widget): os.popen("start-stop-daemon --stop -x /usr/sbin/gsmd") time.sleep(2) ## libgsmd-tool will flush some outdated data self.start_gsmd_btn.set_sensitive(1) self.stop_gsmd_btn.set_sensitive(0) self.state_changed("Off") def start_gsmd(self, widget): # restart not working yet - using stop and start if process_running("pppd"): mbox = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_YES_NO, "There seems to be a GPRS connection runnung.\nDo you want to close it?") response = mbox.run() mbox.hide() mbox.destroy() if response == gtk.RESPONSE_YES: print "will terminate pppd" os.system("start-stop-daemon --stop -x %s" % (PPP_INIT)) os.system("%s stop" %(GSMD_INIT)) print "executing: %s start" %(GSMD_INIT) os.system("%s start" %(GSMD_INIT)) time.sleep(0.5) self.link_quality_changed("0 0 0 0 0") self.network_registration_changed("? ? ? ? ? ? ? ? ? ? ?") self.start_gsmd_btn.set_sensitive(0) self.stop_gsmd_btn.set_sensitive(1) time.sleep(1) ## give the gsmd some time to init... :-/ self.reinit_libgsmd_tool(None) def reinit_libgsmd_tool(self, widget): if not self.start_gsm_tool(): print "error starting gsm-tool - abort reinit" return self.link_quality_changed("0 0 0 0 0") self.network_registration_changed("? ? ? ? ? ? ? ? ? ? ?") self.state_changed("Init") self.operator_changed("? ? ? ? ?") def get_cur_sig_strength(self): # ToDo - parse everything! return 0 #ToDo ## change output on "state bar" def update_state(self, string): self.state_entry.set_text(string) def create_notebook_page(self): self.set_border_width(0) top_btn_box = gtk.HBox(False, 0) self.start_gsmd_btn = gtk.Button("Start\ngsmd") self.start_gsmd_btn.connect("clicked", self.start_gsmd) top_btn_box.add(self.start_gsmd_btn) self.stop_gsmd_btn = gtk.Button("Stop\ngsmd") self.stop_gsmd_btn.connect("clicked", self.stop_gsmd) top_btn_box.add(self.stop_gsmd_btn) self.pack_start(top_btn_box, False, False, 0) # signal Quality frame = gtk.Frame("Signal Stength") box = gtk.VBox() box.set_border_width(15) self.scale_adj = gtk.Adjustment(self.get_cur_sig_strength(), 0.0, 100, 1.0, 1.0, 0.0) self.sig_stength_scale = gtk.ProgressBar(self.scale_adj) self.sig_stength_scale.set_text("0.0 %") box.add(self.sig_stength_scale) frame.add(box) self.pack_start(frame, False, False, 1) # cell info cell_frame = gtk.Frame("Cell Information") cell_box = gtk.VBox() cell_box.set_border_width(15) self.area_code_lbl = gtk.Label("Location Area Code: ?") cell_box.add(self.area_code_lbl) self.cell_id_lbl = gtk.Label("Cell ID: ?") cell_box.add(self.cell_id_lbl) self.operator_lbl = gtk.Label("Operator: ?") cell_box.add(self.operator_lbl) cell_frame.add(cell_box) self.pack_start(cell_frame, False, False, 0) # state state_frame = gtk.Frame("GSM State") state_box = gtk.HBox() state_box1 = gtk.VBox() state_box2 = gtk.VBox() state_box.set_border_width(15) self.lib_state_cbtn = gtk.CheckButton("Init") self.lib_state_cbtn.set_sensitive(1) self.lib_state_cbtn.connect("released", self.reinit_libgsmd_tool) state_box1.add(self.lib_state_cbtn) self.power_state_cbtn = gtk.CheckButton("Power") self.power_state_cbtn.set_sensitive(1) self.power_state_cbtn.connect("released", self.power_cb_changed) state_box1.add(self.power_state_cbtn) self.reg_state_cbtn = gtk.CheckButton("Register") self.reg_state_cbtn.set_sensitive(1) self.reg_state_cbtn.connect("released", self.register_cb_changed) state_box2.add(self.reg_state_cbtn) self.connected_state_cbtn = gtk.CheckButton("Connected") self.connected_state_cbtn.set_sensitive(0) state_box2.add(self.connected_state_cbtn) state_box.add(state_box1) state_box.add(state_box2) state_frame.add(state_box) self.pack_start(state_frame, False, False, 0) state_bar_box = gtk.VBox() self.state_entry = gtk.Entry() self.state_entry.set_text("") self.state_entry.set_sensitive(0) state_bar_box.add(self.state_entry) self.pack_start(state_bar_box, False, False, 0) self.show_all()