1 Star 0 Fork 8

Glin/Minicontrol

forked from 调试中.../Minicontrol 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
DialogChooseDevice.py 2.08 KB
一键复制 编辑 原始数据 按行查看 历史
import os
from PyQt4 import QtGui
from PyQt4.QtGui import QButtonGroup
from AdbUtils import adb_execute, adb_get_devices
from Dialog_Choose_Device import Ui_Choose_Device
class DialogChooseDevice(QtGui.QDialog):
def __init__(self, parent=None, device_serial=None):
super(DialogChooseDevice, self).__init__(parent)
self.dialog = Ui_Choose_Device()
self.dialog.setupUi(self)
self.info_list = []
self.device_serial = device_serial
self.button_group = QButtonGroup()
self.update_device(self.device_serial)
def update_device(self, device_serial=None):
self.info_list, has = adb_get_devices()
item = self.dialog.verticalLayout_2.takeAt(0)
while item:
self.dialog.verticalLayout_2.removeItem(item)
item.widget().setParent(None)
item = self.dialog.verticalLayout_2.takeAt(0)
if len(self.info_list) > 0:
if device_serial is None or len(device_serial) <= 1:
device_serial = self.info_list[0]["serial"]
else:
label = QtGui.QLabel()
label.setText("No device")
self.dialog.verticalLayout_2.insertWidget(0, label)
return
for index in range(len(self.info_list)):
info = self.info_list[index]
radio_button = QtGui.QRadioButton()
radio_button.setText(info["info"])
self.dialog.verticalLayout_2.insertWidget(index, radio_button)
self.button_group.addButton(radio_button)
if device_serial == info["serial"]:
radio_button.setChecked(True)
def get_select_item(self):
index = 0
item = self.dialog.verticalLayout_2.takeAt(0)
while item:
widget = item.widget()
if isinstance(widget, QtGui.QRadioButton):
if widget.isChecked():
return self.info_list[index]
index = index + 1
item = self.dialog.verticalLayout_2.takeAt(0)
return None
def on_refresh_click(self):
self.update_device(self.device_serial)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/Gsiao/minicontrol.git
git@gitee.com:Gsiao/minicontrol.git
Gsiao
minicontrol
Minicontrol
master

搜索帮助