def __init__(self): super().__init__() self.setupUi(self) self.setObjectName("Terminal 1.1") self.setMinimumSize(550, 250) self.richEdit.setReadOnly(True) self.btn_connect.move(self.width()- self.btn_connect.width() - 10, 60) #self.btn_connect.setStyleSheet("") self.btn_disconnect.move(self.width() - self.btn_disconnect.width() - 10, self.btn_disconnect.height() + 60 + 10) self.btn_file_save.move(self.width() - self.btn_file_save.width() - 10, self.height() - self.btn_file_save.height() - 15) # Если опустить ниже появится ошибка # костыль для второго окна UPD: уже нет, так как некторые настройки находятся в главном окне self.thread = WorkThread() self.comboBox_num_port.addItems(self.thread.serial_ports()) self.comboBox_num_port.setEnabled(False) self.add_function() self.add_event() self.widget = SettingsWindow(self) baudrates = ['1200','2400', '4800', '9600', '19200', '38400', '57600', '115200'] self.comboBox_baudrate.addItems(baudrates); self.comboBox_baudrate.setCurrentText('9600') self.widget.comboBox_baudrate.addItems(baudrates); self.widget.comboBox_baudrate.setCurrentText('9600') self.statusbar.setStyleSheet("border :3px solid black;") self.label_1 = QLabel(f'{self.thread.get_count_msg()}') self.statusbar.addPermanentWidget(self.label_1)
class LoginWindow(QMainWindow): def __init__(self): super(LoginWindow, self).__init__() loadUi('UI/login_window.ui', self) self.register_button.clicked.connect(self.go_to_register_page) self.login_button.clicked.connect(self.login) self.popup = QMessageBox() self.popup.setWindowTitle("Failed") self.show() # Open registration page def go_to_register_page(self): webbrowser.open('http://127.0.0.1:8000/register/') # Login function that manages the token authentication def login(self): try: url = 'http://127.0.0.1:8000/api/get_auth_token/' response = requests.post(url, data={ 'username': self.username_input.text(), 'password': self.password_input.text() }) json_response = json.loads(response.text) # HTTP 200 if response.ok: # Open settings window self.open_settings_window(json_response['token']) # Bad response else: # Show error self.popup.setText("Username or Password is not correct") self.popup.exec_() except: # Unable to access server self.popup.setText("Unable to access server") self.popup.exec_() # Opens settings window, passes the received token and closes login window def open_settings_window(self, token): self.settings_window = SettingsWindow(token) self.settings_window.displayInfo() self.close()
def show_settings(controls=None, title="", callback=None, item=None, custom_button=None, mod=None): """ Muestra la ventana de configuración :param controls: :param title: :param callback: :param item: :param custom_button: :param mod: :return: """ from settings_window import SettingsWindow skin = 'Estuary' if xbmc.getSkinDir() == 'skin.estuary' else 'Default' return SettingsWindow("ChannelSettings.xml", sysinfo.runtime_path, skin).start(controls=controls, title=title, callback=callback, item=item, custom_button=custom_button, mod=mod)
def main(): root = Tk() root.geometry(DEFAULT_WINDOW_SIZE) root.title("The New Notepad, TM") editor_settings = EditorSettings() tab_controller = TextTabController(root, editor_settings) menubar = Menu(root) root["menu"] = menubar file_menu = Menu(menubar) menubar.add_cascade(label="File", menu=file_menu) file_menu.add_command( label="New Tab", command=lambda: tab_controller.create_tab(editor_settings)) file_menu.add_command(label="Delete Tab", command=tab_controller.delete_current_tab) file_menu.add_command(label="Save", command=tab_controller.save_current_tab) file_menu.add_command(label="Open", command=tab_controller.open_to_current_tab) file_menu.add_command( label="Settings", command=lambda: SettingsWindow(root, tab_controller, editor_settings)) root.mainloop()
def show_sync_settings(self, url=None, username=None, password=None): self.settings_window = SettingsWindow( self.settings_manager.sync_manager, self.nam, url=self.settings_manager.sync_manager.server_address, username=self.settings_manager.sync_manager.username, password=self.settings_manager.sync_manager.password, certificate=self.settings_manager.sync_manager.certificate) self.settings_window.finished.connect(self.sync_clicked)
def __init__(self, version, share_path): #FIXME: self.settings_dlg=gtk.glade.XML(share_path+"/glade/settings.glade").get_widget("dlgSettings") gnome.init("pyterm", version) self.settings_dlg = SettingsWindow() self.profiles = conf().profiles self.conf = conf() self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("delete_event", self.delete_event) self.window.connect("destroy", lambda w: gtk.main_quit()) self.window.connect("key-press-event", self.key_press) self.nb = gui.TerminalNotebook(self) self.window.add(self.nb) self.nb.create_tabs(conf().sessions) self.nb.set_scrollable(True) # TODO: make settings self.window.show_all() self.window.set_focus(self.nb.terminals[0]['term']) conf().main = self self.update_ui()
def settings(self): self.sett_window = SettingsWindow()
from dearpygui import core, simple from settings_window import SettingsWindow core.enable_docking() settingsWindow = SettingsWindow() core.set_main_window_title("NeuronApplication") with simple.window('MainWindow'): core.add_menu_bar("MenuBar") with simple.menu("Motyw##demo"): core.add_menu_item("Ciemny", callback=lambda sender, data: core.set_theme("Dark"), check=True) core.add_menu_item("Jasny", callback=lambda sender, data: core.set_theme("Light"), check=True) core.add_menu_item("Klasyczny", callback=lambda sender, data: core.set_theme("Classic"), check=True) core.add_menu_item("Ciemny 2", callback=lambda sender, data: core.set_theme("Dark 2"), check=True) core.add_menu_item("Szary", callback=lambda sender, data: core.set_theme("Grey"), check=True) core.add_menu_item("Ciemno-Szary", callback=lambda sender, data: core.set_theme("Dark Grey"), check=True) core.add_menu_item("Wisniowy", callback=lambda sender, data: core.set_theme("Cherry"), check=True) core.add_menu_item("Purpurowy", callback=lambda sender, data: core.set_theme("Purple"), check=True) core.add_menu_item("Zloty", callback=lambda sender, data: core.set_theme("Gold"), check=True) core.add_menu_item("Czerwony", callback=lambda sender, data: core.set_theme("Red"), check=True) with simple.menu("Pozycja"): core.add_menu_item("Zresetuj wszystko", callback=lambda sender, data: settingsWindow.reset_all()) pass with simple.menu("Ukryj"): core.add_menu_item("Okno ustawien", callback = lambda sender, data: settingsWindow.toggle_visibility()) core.add_menu_item("Wizualizacja sieci", callback = lambda sender, data: settingsWindow.betterVisualizer.toggle_visibility()) core.add_menu_item("Wczytaj plik", callback = lambda sender, data: settingsWindow.importWindow.toggle_visibility()) core.add_menu_item("Odpowiedz sieci", callback = lambda sender, data: settingsWindow.outputVisualisationWindow.toggle_visibility()) core.add_menu_item("Historia uczenia##temp2", callback = lambda sender, data: settingsWindow.historyGraphWindow.toggle_visibility())
def show_settings(self): self.setWindowOpacity(0.) settings_window = SettingsWindow(self) settings_window.show()
def open_settings_window(self, token): self.settings_window = SettingsWindow(token) self.settings_window.displayInfo() self.close()
class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): def __init__(self): super().__init__() self.setupUi(self) self.setObjectName("Terminal 1.1") self.setMinimumSize(550, 250) self.richEdit.setReadOnly(True) self.btn_connect.move(self.width()- self.btn_connect.width() - 10, 60) #self.btn_connect.setStyleSheet("") self.btn_disconnect.move(self.width() - self.btn_disconnect.width() - 10, self.btn_disconnect.height() + 60 + 10) self.btn_file_save.move(self.width() - self.btn_file_save.width() - 10, self.height() - self.btn_file_save.height() - 15) # Если опустить ниже появится ошибка # костыль для второго окна UPD: уже нет, так как некторые настройки находятся в главном окне self.thread = WorkThread() self.comboBox_num_port.addItems(self.thread.serial_ports()) self.comboBox_num_port.setEnabled(False) self.add_function() self.add_event() self.widget = SettingsWindow(self) baudrates = ['1200','2400', '4800', '9600', '19200', '38400', '57600', '115200'] self.comboBox_baudrate.addItems(baudrates); self.comboBox_baudrate.setCurrentText('9600') self.widget.comboBox_baudrate.addItems(baudrates); self.widget.comboBox_baudrate.setCurrentText('9600') self.statusbar.setStyleSheet("border :3px solid black;") self.label_1 = QLabel(f'{self.thread.get_count_msg()}') self.statusbar.addPermanentWidget(self.label_1) def add_event(self): self.resizeEvent = self.resize_event def resize_event(self, event): self.btn_connect.move(self.width() - self.btn_connect.width() - 10, 60) self.btn_disconnect.move(self.width() - self.btn_disconnect.width() - 10, self.btn_disconnect.height() + 60 + 10) self.btn_file_save.move(self.width() - self.btn_file_save.width() - 10, self.height() - self.btn_file_save.height() - self.statusbar.height() - 15) self.richEdit.setGeometry(QRect(0, 50, self.width()-120, self.height() - 80)) self.header.setGeometry(QRect(0, 0, self.width(), 50)) self.btn_header_settings.move(self.width() - 30, 17) self.btn_clear.move(self.width() - 60, 17) def add_function(self): self.btn_connect.clicked.connect(self.connect) self.btn_disconnect.clicked.connect(self.disconnect) self.btn_file_save.clicked.connect(self.file_save) self.btn_header_settings.clicked.connect(self.form_settings_open) self.btn_clear.clicked.connect(self.clear) self.comboBox_baudrate.currentTextChanged.connect(self.on_selection_changed_baudrate) def on_threadSignal(self, text): #if text[:-1] == '\n' and text[:2] == '\n': text = text[0:-1] # удаляем последний элемент text = text[0:-1] # удаляем предпоследний элемент, который стал последним self.richEdit.appendPlainText(text) self.label_1.setText(f'{self.thread.get_count_msg()}') # При выключении питания из файла данные удаляются #with open('meridian_m_log.html', 'a') as f: # f.write(text) #f.writelines(lines) f = open("meridian_m_log.html", "a") f.write(text) f.close() def disconnect(self): if(self.thread and self.thread.get_state() == 1): self.thread.close_thread() self.statusbar.showMessage("Отключено", 3000) self.btn_state.setStyleSheet("background-color: rgb(255, 112, 93);") def connect(self): if self.thread.get_state() == 0: self.thread = WorkThread() self.thread.threadSignal.connect(self.on_threadSignal) self.thread.start() # Adding a temporary message self.btn_state.setStyleSheet("background-color: rgb(94, 255, 35);") if self.thread.get_state() == 1: self.statusbar.showMessage("Подключено", 3000) self.btn_connect.setEnabled(False) QTimer.singleShot(5000, lambda: self.btn_connect.setDisabled(False)) else: self.statusbar.showMessage("Не удалось подключиться", 3000) def file_save(self): print("open log file") with open('output.html', 'w') as fout: fout.write(str(self.richEdit.toPlainText())) print("close log file") self.statusbar.showMessage("Файл сохранен", 3000) def form_settings_open(self): self.widget.comboBox_num_port.addItems(self.thread.serial_ports()) self.widget.show() def clear(self): self.richEdit.clear() def on_selection_changed_baudrate(self): self.thread.set_baudrate(int(self.comboBox_baudrate.currentIndex())) print(self.comboBox_baudrate.currentText()) pass def set_combobox_bauderate(self): pass #index = self.comboBox_baudrate.findText(str(self.thread.get_baudrate), Qt.MatchFixedString) #if index >= 0: # self.comboBox_baudrate.setCurrentIndex(index) def closeEvent(self, event): reply = QtWidgets.QMessageBox.question(self, 'Информация', "Вы хотите закрыть все окна?", QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No) if reply == QtWidgets.QMessageBox.Yes: # Видимо надо добавлять все формы сюда self.widget.close() event.accept() else: event.ignore()