def __init__(self): # Call the constructor of our parent class super().__init__() # Layout manager self.scrollableArea = Frame(self, width=512, height=500) self.scrollableArea.pack(fill=BOTH, side=LEFT, expand=1) self.myCanvas = Canvas(self.scrollableArea) self.myCanvas.pack(side=LEFT, fill=BOTH, expand=1) self.scrollY = Scrollbar(self.scrollableArea, orient=VERTICAL, command=self.myCanvas.yview) self.scrollY.pack(side=RIGHT, fill=Y) self.myCanvas.configure(yscrollcommand=self.scrollY.set) self.myCanvas.bind( '<Configure>', lambda e: self.myCanvas.configure( scrollregion=self.myCanvas.bbox("all"))) self.componentsFrame = Frame(self.myCanvas) self.myCanvas.create_window((0, 0), window=self.componentsFrame, anchor="nw") self.formFrame = Frame(self, width=512, height=500) self.formFrame.pack(fill=BOTH, side=RIGHT, expand=True) menu = MenuBar(self) menuBar = menu.setMenu() self.config(menu=menuBar) self.resetConfig() self.reloadComponentFrame() self.mininet = None
def __init__(self): super().__init__() self.geometry('1280x720') self.minsize(690, 570) self.menubar = MenuBar(self) self.config(menu=self.menubar)
def __init__(self): super(Window, self).__init__() # Configure the window properties: size and name self.setGeometry(50, 50, 1920, 1080) self.setWindowTitle("Quadcopter Visualizer") # Configure the menu bar at the top of the window self.menu_bar = MenuBar() self.setMenuBar(self.menu_bar) self.menu_bar.set_serial_callback(self.open_serial_port) # Setup periodic refreshing of the menu bar. self.menu_bar_timer = QtCore.QTimer() self.menu_bar_timer.timeout.connect(self.menu_bar.refresh) self.menu_bar_timer.setInterval(100) self.menu_bar_timer.start() self.serial = QtSerialPort.QSerialPort() # Setup the main widget and start the GUI. self.main_widget = MainWidget(self) self.setCentralWidget(self.main_widget) self.show()
import tkinter as tk from fileManagement import FileManagement from menu import MenuBar if __name__ == "__main__": # create the required objects top = tk.Tk() file_management = FileManagement(top) menuBar = MenuBar(top, file_management) # build the basic window top.geometry("300x300") # set the window size top.resizable(0, 0) # stop resizing # display the menu top.config(menu=menuBar.get_menu()) top.title("Patient Management") top.mainloop()
def create_menubar(self): self.master.config(menu=MenuBar(self))
class Window(QtWidgets.QMainWindow): """ Main window which inherits from QMainWindow. Everything is contained within this. Attributes ---------- menu_bar : MenuBar Menu bar which will go at the top of the menu. menu_bar_timer : QTimer Timer to periodically call the refresh function of the menu bar. main_widget : MainWidget Main widget which will contain everything other than the menu bar. serial : QSerialPort Serial port from which to read and send data. Methods ---------- """ def __init__(self): super(Window, self).__init__() # Configure the window properties: size and name self.setGeometry(50, 50, 1920, 1080) self.setWindowTitle("Quadcopter Visualizer") # Configure the menu bar at the top of the window self.menu_bar = MenuBar() self.setMenuBar(self.menu_bar) self.menu_bar.set_serial_callback(self.open_serial_port) # Setup periodic refreshing of the menu bar. self.menu_bar_timer = QtCore.QTimer() self.menu_bar_timer.timeout.connect(self.menu_bar.refresh) self.menu_bar_timer.setInterval(100) self.menu_bar_timer.start() self.serial = QtSerialPort.QSerialPort() # Setup the main widget and start the GUI. self.main_widget = MainWidget(self) self.setCentralWidget(self.main_widget) self.show() def open_serial_port(self, port: str): """ Open a new serial port. Close any port currently open. Parameters ---------- port : str Name of the port to open. """ if self.serial.isOpen() is True: self.serial.close() self.serial.setPortName(port) self.serial.setBaudRate(115200) self.serial.readyRead.connect(self.parse_serial) self.serial.open(QtCore.QIODevice.OpenModeFlag.ReadWrite) def parse_serial(self): """ """ while self.serial.canReadLine(): string = bytes(self.serial.readLine()).decode("ascii") self.main_widget.terminal_frame.write(string) # if string.count("flight controller - start") > 0: # for key in self.main_widget.data_frame.accel_data.keys(): # self.main_widget.data_frame.accel_data[key] = [0] # for key in self.main_widget.data_frame.gyro_data.keys(): # self.main_widget.data_frame.gyro_data[key] = [0] if string.count("DATA:TIME:") > 0: data = string[len("DATA:TIME:"):-len("\n")] self.main_widget.data_frame.accel_data.timestamp.append( int(data)) self.main_widget.data_frame.gyro_data.timestamp.append( int(data)) self.main_widget.data_frame.orientation_data.timestamp.append( int(data)) elif string.count("DATA:KBANK:") > 0: data = string[len("DATA:KBANK:"):-len("\n")] self.main_widget.data_frame.orientation_data.fields[ "Bank"].append(int(data)) elif string.count("DATA:KATTITUDE:") > 0: data = string[len("DATA:KATTITUDE:"):-len("\n")] self.main_widget.data_frame.orientation_data.fields[ "Attitude"].append(int(data)) elif string.count("DATA:KHEADING:") > 0: data = string[len("DATA:KHEADING:"):-len("\n")] self.main_widget.data_frame.orientation_data.fields[ "Heading"].append(int(data)) elif string.count("DATA:ACCELX:") > 0: data = string[len("DATA:ACCELX:"):-len("\n")] self.main_widget.data_frame.accel_data.fields["X"].append( int(data)) elif string.count("DATA:ACCELY:") > 0: data = string[len("DATA:ACCELY:"):-len("\n")] self.main_widget.data_frame.accel_data.fields["Y"].append( int(data)) elif string.count("DATA:ACCELZ:") > 0: data = string[len("DATA:ACCELZ:"):-len("\n")] self.main_widget.data_frame.accel_data.fields["Z"].append( int(data)) elif string.count("DATA:GYROROLL:") > 0: data = string[len("DATA:GYROROLL:"):-len("\n")] self.main_widget.data_frame.gyro_data.fields["Roll"].append( int(data)) elif string.count("DATA:GYROPITCH:") > 0: data = string[len("DATA:GYROPITCH:"):-len("\n")] self.main_widget.data_frame.gyro_data.fields["Pitch"].append( int(data)) elif string.count("DATA:GYROYAW:") > 0: data = string[len("DATA:GYROYAW:"):-len("\n")] self.main_widget.data_frame.gyro_data.fields["Yaw"].append( int(data))
def __init__(self): tk.Tk.__init__(self) # root tk instance self.title("Sandbox example: Integrating Tkinter GUI elements as classes") # title of our master widget self.geometry("800x300") # root window size menubar = MenuBar(self) # create menu bar instance self.config(menu=menubar) # add menu bar to app
def __init__(self): tk.Tk.__init__(self) menubar = MenuBar(self) tool = toolBar(self) self.config(menu=menubar)
def toggle_diagonal(diagonal): global diagonal_move diagonal_move = diagonal if current_map: current_map.pathfind_grid.diagonal_movement = diagonal # Initialize create_screen((app_width, app_height)) pygame.display.set_caption('Grid Game') icon = pygame.image.load('images/wizard.png') pygame.display.set_icon(icon) cursor.create_cursor() init_map('map1') main_menu = MenuBar(screen, size=[app_width, menu_height]) menu0 = main_menu.add_menu('Maps') menu1 = main_menu.add_menu('Tiles') menu2 = main_menu.add_menu('Settings') menu0.add_item('Map1', command=(init_map, 'map1'), selected=True) menu0.add_item('Map2', command=(init_map, 'map2')) menu0.add_item('Map3', command=(init_map, 'map3')) menu1.add_item('16px', command=(resize_tiles, 16)) menu1.add_item('32px', command=(resize_tiles, 32), selected=True) menu1.add_item('48px', command=(resize_tiles, 48)) menu1.add_item('64px', command=(resize_tiles, 64)) menu2.add_item('Diagonal on', command=(toggle_diagonal, True)) menu2.add_item('Diagonal off', command=(toggle_diagonal, False), selected=True) def handle_kb_input():