def open_gui(self): self.main = MainWindow(self) self.main.setFixedSize(730, 430) self.main.setWindowIcon(QIcon(os.path.join(ProgramPath.program_path(), "demo-icon.png"))) self.tabs = QTabWidget() widget = QWidget() layout = QVBoxLayout() layout.addWidget(self.tabs) widget.setLayout(layout) self.main.setCentralWidget(widget) self.projects.append(ProjectEnvDisplay(self.tabs, self)) self.projects.append(ProjectStatistics(self.tabs, self)) self.projects.append(ProjectXively(self.tabs, self)) self.tabs.addTab(self.projects[0], "Display Environment Measurements") self.tabs.addTab(self.projects[1], "Show Statistics with Button Control") self.tabs.addTab(self.projects[2], "Connect to Xively") self.active_project = self.projects[0] self.tabs.currentChanged.connect(self.tabChangedSlot) self.main.setWindowTitle("Starter Kit: Weather Station Demo " + config.DEMO_VERSION) self.main.show()
def bmp_to_pixmap(path): absolute_path = os.path.join(ProgramPath.program_path(), path) pixmap = QPixmap(absolute_path) mask1 = pixmap.createMaskFromColor(QColor(0xFF, 0x00, 0XF0), Qt.MaskInColor) pixmap.setMask(mask1) return pixmap
def __init__(self, parent=None): QMainWindow.__init__(self, parent) self.setupUi(self) self.setWindowIcon(QIcon(os.path.join(ProgramPath.program_path(), "brickv-icon.png"))) signal.signal(signal.SIGINT, self.exit_brickv) signal.signal(signal.SIGTERM, self.exit_brickv) self.async_thread = async_start_thread(self) self.setWindowTitle("Brick Viewer " + config.BRICKV_VERSION) self.tree_view_model_labels = ['Name', 'UID', 'FW Version'] self.tree_view_model = QStandardItemModel() self.tree_view.setModel(self.tree_view_model) self.set_tree_view_defaults() # Remove dummy tab self.tab_widget.removeTab(1) self.last_tab = 0 self.name = '<unknown>' self.uid = '<unknown>' self.version = (0, 0, 0) self.disconnect_times = [] self.qtcb_enumerate.connect(self.cb_enumerate) self.qtcb_connected.connect(self.cb_connected) self.qtcb_disconnected.connect(self.cb_disconnected) self.ipcon = IPConnection() self.ipcon.register_callback(IPConnection.CALLBACK_ENUMERATE, self.qtcb_enumerate.emit) self.ipcon.register_callback(IPConnection.CALLBACK_CONNECTED, self.qtcb_connected.emit) self.ipcon.register_callback(IPConnection.CALLBACK_DISCONNECTED, self.qtcb_disconnected.emit) self.flashing_window = None self.advanced_window = None self.delayed_refresh_updates_timer = QTimer() self.delayed_refresh_updates_timer.timeout.connect(self.delayed_refresh_updates) self.delayed_refresh_updates_timer.setInterval(500) self.reset_view() self.button_advanced.setDisabled(True) self.tab_widget.currentChanged.connect(self.tab_changed) self.connect.pressed.connect(self.connect_pressed) self.button_flashing.pressed.connect(self.flashing_pressed) self.button_advanced.pressed.connect(self.advanced_pressed) self.plugin_manager = PluginManager() self.combo_host.addItem(config.get_host()) self.combo_host.addItems(config.get_host_history(HOST_HISTORY_SIZE - 1)) self.spinbox_port.setValue(config.get_port()) self.last_host = self.combo_host.currentText() self.last_port = self.spinbox_port.value()
def make_gui(self): self.main = MainWindow(self) self.main.setWindowIcon(QIcon(os.path.join(ProgramPath.program_path(), "demo-icon.png"))) self.tabs = QTabWidget() widget = QWidget() layout = QVBoxLayout() layout.addWidget(self.tabs) widget.setLayout(layout) self.main.setCentralWidget(widget) self.setup = SetupWidget(self.tabs, self) self.tetris = TetrisWidget(self.tabs, self) self.pong = PongWidget(self.tabs, self) self.fire = FireWidget(self.tabs, self) self.text = TextWidget(self.tabs, self) self.images = ImagesWidget(self.tabs, self) self.rainbow = RainbowWidget(self.tabs, self) self.projects.append(self.setup) self.projects.append(self.tetris) self.projects.append(self.pong) self.projects.append(self.fire) self.projects.append(self.text) self.projects.append(self.images) self.projects.append(self.rainbow) self.tabs.addTab(self.setup, "Setup") self.tabs.addTab(self.tetris, "Tetris") self.tabs.addTab(self.pong, "Pong") self.tabs.addTab(self.fire, "Fire") self.tabs.addTab(self.text, "Text") self.tabs.addTab(self.images, "Images") self.tabs.addTab(self.rainbow, "Rainbow") self.active_project = self.projects[0] self.tabs.currentChanged.connect(self.tab_changed_slot) self.main.setWindowTitle("Starter Kit: Blinkenlights Demo " + config.DEMO_VERSION) self.main.show()
def __init__(self): self.plugins = [] d = os.path.join(ProgramPath.program_path(), 'plugin_system/plugins/') for p in os.listdir(d): if os.path.isdir(os.path.join(d, p)): try: m = __import__('plugins', globals(), locals(), [p], -1) except ImportError: print('Exception in plugin: ' + str(p)) continue module = getattr(m, p) try: device_class = module.device_class except AttributeError: print('Exception in plugin: ' + str(p)) device_class = None print('Found plugin: ' + str(p)) if device_class: self.plugins.append(device_class)
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. """ import sys from program_path import ProgramPath # Append path to sys.path (such that plugins can import ip_connection) __path = ProgramPath.program_path() if not __path in sys.path: sys.path.insert(0, __path) import logging import config #import PyQt4 from PyQt4.QtGui import QApplication from mainwindow import MainWindow logging.basicConfig(level=config.LOGGING_LEVEL, format=config.LOGGING_FORMAT, datefmt=config.LOGGING_DATEFMT) if __name__ == "__main__":
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. """ import sys from program_path import ProgramPath # Append path to sys.path (such that plugins can import ip_connection) __path = ProgramPath.program_path() if not __path in sys.path: sys.path.insert(0, __path) import logging import config # import PyQt4 from PyQt4.QtGui import QApplication from mainwindow import MainWindow logging.basicConfig(level=config.LOGGING_LEVEL, format=config.LOGGING_FORMAT, datefmt=config.LOGGING_DATEFMT) if __name__ == "__main__": app = QApplication(sys.argv)