Exemplo n.º 1
0
    def __init__(self):
        self.width = 1380
        self.height = 600
        self.border_width = 15
        self.paint_area_width = int(self.width * 2 / 3 - 2 * self.border_width)
        self.paint_area_height = int(self.height - 2 * self.border_width)

        self.border = pygame.image.load(os.path.join("imgs", "border.png"))
        self.border = pygame.transform.scale(
            self.border, (self.border_width * 2 + self.paint_area_width,
                          self.border_width * 2 + self.paint_area_height))
        self.sidebar = sidebar.Sidebar(self.width / 3, self.height,
                                       (self.width * 2 / 3, 0))
        self.bg = pygame.image.load(os.path.join("imgs", "bg.jpg"))
        self.bg = pygame.transform.scale(
            self.bg, (self.paint_area_width, self.paint_area_height))

        self.countries = countries_init(self.paint_area_width,
                                        self.paint_area_height,
                                        self.border_width, 8)
        self.World = world.World(self.countries)
        self.selected_county = self.World
        self.is_country_infected = False
        self.has_healthy = True
        self.infection_probability = create_infection()
        self.country_index = 0
        self.days_passed = 0
        self.speed = 1

        self.win = pygame.display.set_mode((self.width, self.height))
        self.sidebar.update(self.selected_county, self.days_passed, self.speed)
Exemplo n.º 2
0
 def __init__(self, config):
     QtGui.QMainWindow.__init__(self)
     
     self.config = config
     
     self.setWindowTitle('Zonu BBS Viewer')
     self.resize(*config.main_window_size)
     
     # Build the menu
     menu_bar = self.menuBar()
     bbs_menu = menu_bar.addMenu('&BBS')
     
     self.about_action = QtGui.QAction('About', self)
     self.about_action.setStatusTip('About Zonu')
     
     self.exit_action = QtGui.QAction('Exit', self)
     self.exit_action.setStatusTip('Exit Zonu')
     
     bbs_menu.addAction(self.about_action)
     bbs_menu.addAction(self.exit_action)
     
     # Put the sidebar and the right panel in an vsplitter        
     self.vsplitter = QtGui.QSplitter(self)
     self.sidebar = sidebar.Sidebar(self, self.config)
     self.content = welcomescreen.WelcomeScreen(self).get_main_widget()
     
     self.vsplitter.addWidget(self.sidebar)
     self.vsplitter.addWidget(self.content)
     
     self.setCentralWidget(self.vsplitter)
Exemplo n.º 3
0
    def makeWidgets_sidebar(self):
        self.sidebar = Side.Sidebar(self)
        treeselection = self.sidebar.treeview.get_selection()
        self.sidebar.select_signal = treeselection.connect(
            "changed", self.sidebar_on_row_changed)

        for obj in self.sidebar.track_FONT:
            obj.modify_font(FONT_obj)
        return self.sidebar
Exemplo n.º 4
0
    def __init__(self):
        super(MainWindow, self).__init__()

        """import irc
        from twisted.internet import reactor
        irc.log.startLogging(sys.stdout)
        self.f = irc.LogBotFactory('#pangaea', '/tmp/foo')
        reactor.connectTCP("irc.freenode.net", 6667, self.f)
        reactor.runReturn()"""

        self.mdiArea = QtGui.QMdiArea()
        self.mdiArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
        self.mdiArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)

        import sidebar
        self.document = sidebar.Sidebar()
        self.document.setMainWidget(self.mdiArea)
        self.setCentralWidget(self.document)
        #self.setCentralWidget(self.mdiArea)

        self.createActions()
        #self.createDockWidgets()
        self.createSidebarItems()
        self.createMenus()
        self.createToolBars()
        #self.createStatusBar()
        #self.updateMenus()

        layout = QtGui.QHBoxLayout()
        """self.showtoolbox = QtGui.QPushButton('>')
        self.showtoolbox.setMaximumWidth(20)
        self.showtoolbox.setFlat(True)
        self.showtoolbox.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Ignored)
        layout.addWidget(self.showtoolbox)"""
        """layout.addWidget(self.mdiArea)
        layout.addWidget(self.toolCont)

        self.widget = QtGui.QWidget()
        self.widget.setLayout(layout)
        self.setCentralWidget(self.widget)"""

        #self.splitter = QtGui.QSplitter()
        #self.splitter.addWidget(self.mdiArea)
        #self.splitter.addWidget(self.toolBox)
        #self.setCentralWidget(self.splitter)


        #v = autohide_dock.QAutoHideDockWidgets(QtCore.Qt.LeftDockWidgetArea, self)

        self.setWindowTitle('Kartludox')
        self.setUnifiedTitleAndToolBarOnMac(True)
        self.showMaximized()
        self.createMdiChild()
Exemplo n.º 5
0
    def __init__(self):
        Gtk.Window.__init__(self, title="Noted")
        self.set_border_width(5)
        self.set_size_request(1100, 900)
        self.set_resizable(False)
        # Header Bar
        hbar = hb.Headerbar()
        hbar.connect("destroy", self.close_database)
        self.set_titlebar(hbar)

        # Notebook button
        hbar.notebook_button.connect("clicked", self.create_notebook)

        # Create Button
        hbar.create_button.connect("clicked", self.create_note)

        # Save button
        hbar.save_button.connect("clicked", self.save_note)

        # Delete Button
        hbar.delete_button.connect("clicked", self.delete_note)

        #shortcuts
        self.connect("key-press-event", self.on_key_press)

        # MAIN WINDOW
        main_window = Gtk.Grid(column_homogeneous=False, column_spacing=5)

        # SIDEBAR
        self.sidebar = sb.Sidebar()
        self.sidebar.view.connect("row_activated", self.show_note)
        self.sidebar.view.connect('button-release-event',
                                  self.show_sidebar_options)
        self.sidebar.sidebar_options['new'].connect('activate',
                                                    self.create_note)
        self.sidebar.sidebar_options['delete'].connect('activate',
                                                       self.delete_note)
        self.sidebar.sidebar_options['restore'].connect(
            'activate', self.restore_note)

        # EDITOR
        self.editor = editor.Editor(self)

        # loads the storage file and creates the dict db
        self.start_database()

        main_window.attach(self.sidebar, 0, 0, 1, 2)
        main_window.attach(self.editor, 1, 0, 2, 1)
        self.add(main_window)
Exemplo n.º 6
0
    def __init__(self):
        Gtk.Window.__init__(self, title="Noted")
        self.set_border_width(5)
        self.set_size_request(1000, 800)

        #Header Bar
        hbar = hb.Headerbar()
        hbar.connect("destroy", self.close_database)
        self.set_titlebar(hbar)

        #Notebook button
        hbar.notebook_button.connect("clicked", self.create_notebook)

        #Create Button
        hbar.create_button.connect("clicked", self.create_note)

        #Save button
        hbar.save_button.connect("clicked", self.save_note)

        #Delete Button
        hbar.delete_button.connect("clicked", self.delete_note)

        # MAIN WINDOW
        main_window = Gtk.Grid(column_homogeneous=False, column_spacing=5)

        #SIDEBAR
        self.sidebar = sb.Sidebar()
        self.sidebar.view.connect("row_activated", self.show_note)

        #EDITOR
        self.editor = editor.Editor()

        #loads the storage file and creates the dict db
        self.start_database()

        main_window.attach(self.sidebar, 0, 0, 1, 2)
        main_window.attach(self.editor, 1, 0, 2, 1)
        self.add(main_window)
Exemplo n.º 7
0
    def __init__(self, settings):
        """This is where the magic happens."""

        start_time = time.clock()

        super().__init__()

        self.__settings = settings

        # Ensure the window is not visible until it's ready
        self.set_visible(False)

        self.set_type_hint(Gtk.WindowType.TOPLEVEL)

        # ----------------------------------------------------------------------
        # Set up a domain socket for show/hide messages from the panel
        # button shell extension. This is done early, because if it
        # fails, we simply exit. We can't do *anything* without it.
        # (The only other choice would be to always display the menu,
        # never allowing the user to hide it because without the socket
        # it cannot be reopened.)

        try:
            # Clean leftovers
            os.unlink(self.__settings.socket)
        except OSError:
            pass

        try:
            self.__socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
            self.__socket.bind(self.__settings.socket)
        except Exception as exception:
            # Oh dear...
            logging.error('Unable to create a domain socket for IPC!')
            logging.error('Reason: %s', str(exception))
            logging.error('Socket name: "%s"', self.__settings.socket)
            logging.error('This is a fatal error, stopping here.')

            syslog.syslog(syslog.LOG_CRIT,
                          'PuavoMenu IPC socket "%s" creation failed: %s',
                          self.__settings.socket, str(exception))

            syslog.syslog(syslog.LOG_CRIT,
                          'PuavoMenu stops here. Contact Opinsys support.')

            exit(1)

        # Start listening the socket. Use glib's watch functions, then
        # we don't need to use threads (which work too, but are harder
        # to clean up and we'll run into problems with multihtreaded
        # xlib programs).

        # https://developer.gnome.org/pygobject/stable/glib-functions.html#
        #   function-glib--io-add-watch
        GLib.io_add_watch(self.__socket, GLib.IO_IN, self.__socket_watcher)

        # ----------------------------------------------------------------------

        # Exit stuff. By default the program cannot be exited normally.
        self.__exit_permitted = False
        self.connect('delete-event', self.__try_exit)

        # Program, menu and category data
        self.menudata = None

        # Current category (index to menudata.category_index)
        self.current_category = -1

        # The current menu, if any (None if on category top-level)
        self.current_menu = None

        # The current menu/program buttons in the current
        # category and menu, if any
        self.__buttons = []

        # Storage for 48x48 -pixel program and menu icons. Maintained
        # separately from the menu data.
        self.__icons = iconcache.IconCache(48, 48 * 20)

        # Background image for top-level menus
        try:
            if self.__settings.dark_theme:
                image_name = 'folder_dark.png'
            else:
                image_name = 'folder.png'

            # WARNING: Hardcoded image size!
            self.__menu_background = \
                utils_gui.load_image_at_size(self.__settings.res_dir + image_name, 150, 110)
        except Exception as exception:
            logging.error("Can't load the menu background image: %s",
                          str(exception))
            self.__menu_background = None

        # ----------------------------------------------------------------------
        # Create the window elements

        # Set window style
        if self.__settings.prod_mode:
            self.set_skip_taskbar_hint(True)
            self.set_skip_pager_hint(True)
            self.set_deletable(False)  # no close button
            self.set_decorated(False)
        else:
            # makes developing slightly easier
            self.set_skip_taskbar_hint(False)
            self.set_skip_pager_hint(False)
            self.set_deletable(True)
            self.set_decorated(True)
            self.__exit_permitted = True

        # Don't mess with the real menu when running in development mode
        if self.__settings.prod_mode:
            self.set_title('PuavoMenuUniqueName')
        else:
            self.set_title('DevModePuavoMenu')

        self.set_resizable(False)
        self.set_size_request(WINDOW_WIDTH, WINDOW_HEIGHT)
        self.set_position(Gtk.WindowPosition.CENTER)

        # Top-level container for all widgets. This is needed, because
        # a window can contain only one child widget and we can have
        # dozens of them. Every widget has a fixed position and size,
        # because the menu isn't user-resizable.
        self.__main_container = Gtk.Fixed()
        self.__main_container.set_size_request(WINDOW_WIDTH, WINDOW_HEIGHT)

        if not self.__settings.prod_mode:
            # Create the devtools popup menu
            self.menu_signal = \
                self.connect('button-press-event', self.__devtools_menu)

        # ----------------------------------------------------------------------
        # Menus/programs list

        # TODO: Gtk.Notebook isn't the best choice for this

        # Category tabs
        self.__category_buttons = Gtk.Notebook()
        self.__category_buttons.set_size_request(CATEGORIES_WIDTH, -1)
        self.__category_buttons.connect('switch-page', self.__clicked_category)
        self.__main_container.put(self.__category_buttons, PROGRAMS_LEFT,
                                  MAIN_PADDING)

        # The back button
        self.__back_button = Gtk.Button()
        self.__back_button.set_label('<<')
        self.__back_button.connect('clicked', self.__clicked_back_button)
        self.__back_button.set_size_request(BACK_BUTTON_WIDTH, -1)
        self.__main_container.put(self.__back_button, BACK_BUTTON_X,
                                  BACK_BUTTON_Y)

        # The search box

        # filter unwanted characters from queries
        self.__translation_table = \
            dict.fromkeys(map(ord, "*^?{[]}/\\_+=\"\'#%&()'`@$<>|~"),
                          None)

        self.__search = Gtk.SearchEntry()
        self.__search.set_size_request(SEARCH_WIDTH, SEARCH_HEIGHT)
        self.__search.set_max_length(10)  # you won't need more than this
        self.__search_changed_signal = \
            self.__search.connect('changed', self.__do_search)
        self.__search_keypress_signal = \
            self.__search.connect('key-press-event', self.__search_keypress)
        self.__search.set_placeholder_text(
            utils.localize(STRINGS['search_placeholder'],
                           self.__settings.language))
        self.__main_container.put(
            self.__search,
            PROGRAMS_LEFT + PROGRAMS_WIDTH - SEARCH_WIDTH - MAIN_PADDING,
            MAIN_PADDING)

        # Menu label and description
        self.__menu_title = Gtk.Label()
        self.__menu_title.set_size_request(PROGRAMS_WIDTH, -1)
        self.__menu_title.set_ellipsize(Pango.EllipsizeMode.END)
        self.__menu_title.set_justify(Gtk.Justification.CENTER)
        self.__menu_title.set_alignment(0.0, 0.0)
        self.__menu_title.set_use_markup(True)
        self.__main_container.put(
            self.__menu_title,
            BACK_BUTTON_X + BACK_BUTTON_WIDTH + MAIN_PADDING,
            BACK_BUTTON_Y + 3)

        # The main programs list
        self.__programs_container = Gtk.ScrolledWindow()
        self.__programs_container.set_size_request(PROGRAMS_WIDTH,
                                                   PROGRAMS_HEIGHT)
        self.__programs_container.set_policy(Gtk.PolicyType.NEVER,
                                             Gtk.PolicyType.AUTOMATIC)
        self.__programs_container.set_shadow_type(Gtk.ShadowType.NONE)
        self.__programs_icons = Gtk.Fixed()
        self.__programs_container.add_with_viewport(self.__programs_icons)
        self.__main_container.put(self.__programs_container, PROGRAMS_LEFT,
                                  PROGRAMS_TOP)

        # Placeholder for empty categories, menus and search results
        self.__empty = Gtk.Label()
        self.__empty.set_size_request(PROGRAMS_WIDTH, PROGRAMS_HEIGHT)
        self.__empty.set_use_markup(True)
        self.__empty.set_justify(Gtk.Justification.CENTER)
        self.__empty.set_alignment(0.5, 0.5)
        self.__main_container.put(self.__empty, PROGRAMS_LEFT, PROGRAMS_TOP)

        # Faves list
        self.__faves_sep = Gtk.Separator(
            orientation=Gtk.Orientation.HORIZONTAL)
        self.__faves_sep.set_size_request(PROGRAMS_WIDTH, 1)
        self.__main_container.put(
            self.__faves_sep, PROGRAMS_LEFT,
            PROGRAMS_TOP + PROGRAMS_HEIGHT + MAIN_PADDING)

        self.__faves = faves.FavesList(self, self.__settings)
        self.__faves.set_size_request(PROGRAMS_WIDTH,
                                      PROGRAM_BUTTON_HEIGHT + 2)
        self.__main_container.put(self.__faves, PROGRAMS_LEFT, FAVES_TOP)

        # ----------------------------------------------------------------------
        # The sidebar: the user avatar, buttons, host infos

        utils_gui.create_separator(container=self.__main_container,
                                   x=SIDEBAR_LEFT - MAIN_PADDING,
                                   y=MAIN_PADDING,
                                   w=1,
                                   h=WINDOW_HEIGHT - (MAIN_PADDING * 2),
                                   orientation=Gtk.Orientation.VERTICAL)

        self.__sidebar = sidebar.Sidebar(self, self.__settings)

        self.__main_container.put(self.__sidebar.container, SIDEBAR_LEFT,
                                  SIDEBAR_TOP)

        # ----------------------------------------------------------------------
        # Setup GTK signal handlers

        # Listen for Esc keypresses for manually hiding the window
        self.__main_keypress_signal = \
            self.connect('key-press-event', self.__check_for_esc)

        self.__focus_signal = None

        if not self.__settings.autohide:
            # Keep the window on top of everything and show it
            self.set_visible(True)
            self.set_keep_above(True)
        else:
            # In auto-hide mode, hide the window when it loses focus
            self.enable_out_of_focus_hide()

        self.__search.connect('focus-out-event', self.__search_out)

        # ----------------------------------------------------------------------
        # UI done

        self.add(self.__main_container)
        self.__main_container.show()

        # DO NOT CALL self.show_all() HERE, the window has hidden elements
        # that are shown/hidden on demand. And we don't even have any
        # menu data yet to show.

        end_time = time.clock()
        utils.log_elapsed_time('Window init time', start_time, end_time)

        # ----------------------------------------------------------------------
        # Load menu data

        # Finally, load the menu data and show the UI
        self.load_menu_data()

        # This is a bad, bad situation that should never happen in production.
        # It will happen one day.
        if self.menudata is None or len(self.menudata.programs) == 0:
            if self.__settings.prod_mode:
                self.__show_empty_message(STRINGS['menu_no_data_at_all_prod'])
            else:
                self.__show_empty_message(STRINGS['menu_no_data_at_all_dev'])
    def initUI(self):

        in_class = "menu"

        self.sidebar = sidebar.Sidebar(self)
        self.sidebar.window.connect(self.getvalue)

        self.addDockWidget(Qt.LeftDockWidgetArea, self.sidebar)

        header = AppName(in_class)
        footer = Footer()

        add_and_search = AddSearchFrame(in_class)
        add_and_search.add_button.clicked.connect(lambda: self.add_menu(in_class))
        add_and_search.search_button.clicked.connect(
                                        lambda: self.search_menu(add_and_search.search_box))


        self.table = QTableWidget()
        self.table.setColumnCount(5)
        # self.table.setStyleSheet("border: none")
        # self.table.setStyleSheet(
        #     "background-color: rgb(255, 255, 255);\n"
        #     'font: 10pt "MS Shell Dlg 2";\n'
        #     "color: rgb(30, 45, 66);"
        # )

        # self.table.setHorizontalHeaderItem(0, QTableWidgetItem("ID"))
        self.table.setHorizontalHeaderItem(0, QTableWidgetItem("Food"))
        self.table.setHorizontalHeaderItem(1, QTableWidgetItem("Category"))
        self.table.setHorizontalHeaderItem(2, QTableWidgetItem("Price"))
        # self.table.setHorizontalHeaderItem(3, QTableWidgetItem("Bonus"))
        # self.table.setHorizontalHeaderItem(3, QTableWidgetItem("Joining Date"))
        # self.table.setHorizontalHeaderItem(6, QTableWidgetItem("Total Salary"))
        self.table.setHorizontalHeaderItem(3, QTableWidgetItem("Edit"))
        self.table.setHorizontalHeaderItem(4, QTableWidgetItem("Delete"))


        data = self.load_menu_data()
        print(data)

        for x in data:
            print(x)

        self.populate_table(data)
        self.table.resizeColumnsToContents()

        layout = QVBoxLayout()

        layout.addWidget(header)
        layout.addWidget(add_and_search)
        layout.addWidget(self.table)
        # layout.addStretch()
        layout.addWidget(footer)

        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)

        centralWidget = QWidget()
        centralWidget.setLayout(layout)

        self.setCentralWidget(centralWidget)
        self.setContentsMargins(0, 0, 0, 0)

        # self.resize(800, 600)
        self.setWindowTitle("Employee")
        self.resize(1160, 605)

        self.show()
        self.center()
    def initUI(self):
        self.sidebar = sidebar.Sidebar(self)
        self.sidebar.window.connect(self.getvalue)

        print("Dashboard")
        self.addDockWidget(Qt.LeftDockWidgetArea, self.sidebar)

        header = AppName("dashboard")
        footer = Footer()

        statslabel = QLabel("Statistics")
        statslabel.setStyleSheet("color: rgb(30, 45, 66);"
                                 'font: 75 16pt "MS Shell Dlg 2";')
        statslabel.setContentsMargins(20, 15, 0, 0)

        statistics = QHBoxLayout()

        dashboardsales = DashboardSales()
        dashboardorders = DashboardOrders()
        # dashboardprofits = DashboardProfits()

        statistics.addStretch()
        statistics.addWidget(dashboardsales)
        statistics.addStretch()
        statistics.addWidget(dashboardorders)
        statistics.addStretch()
        # statistics.addWidget(dashboardprofits)
        # statistics.addStretch()

        restaurantlabel = QLabel("Restaurant")
        restaurantlabel.setStyleSheet("color: rgb(30, 45, 66);"
                                      'font: 75 16pt "MS Shell Dlg 2";')
        restaurantlabel.setContentsMargins(20, 0, 0, 0)

        restaurantdetails = RestaurantDetails()

        layout = QVBoxLayout()

        layout.addWidget(header)
        layout.addWidget(statslabel)
        layout.addWidget(HLine())
        layout.addLayout(statistics)
        layout.addWidget(HLine())
        layout.addWidget(restaurantlabel)
        layout.addWidget(HLine())
        layout.addWidget(restaurantdetails)
        layout.addStretch()
        layout.addWidget(footer)

        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)

        centralWidget = QWidget()
        centralWidget.setLayout(layout)

        print("hello")

        self.setCentralWidget(centralWidget)
        self.setContentsMargins(0, 0, 0, 0)

        self.resize(1160, 605)
        self.setWindowTitle("Login")

        self.show()

        self.center()
Exemplo n.º 10
0
    def initUI(self):

        in_class = "tables"

        self.sidebar = sidebar.Sidebar(self)
        self.sidebar.window.connect(self.getvalue)

        self.addDockWidget(Qt.LeftDockWidgetArea, self.sidebar)

        header = AppName(in_class)
        footer = Footer()

        add_and_search = AddSearchFrame(in_class)
        add_and_search.add_button.clicked.connect(
            lambda: self.add_tables(in_class))
        add_and_search.search_button.clicked.connect(
            lambda: self.search_tables(add_and_search.search_box))

        self.table = QTableWidget()
        self.table.setColumnCount(4)
        # self.table.setStyleSheet("border: none")
        # self.table.setStyleSheet(
        #     "background-color: rgb(255, 255, 255);\n"
        #     'font: 10pt "MS Shell Dlg 2";\n'
        #     "color: rgb(30, 45, 66);"
        # )

        # self.table.setHorizontalHeaderItem(0, QTableWidgetItem("ID"))
        self.table.setHorizontalHeaderItem(0, QTableWidgetItem("Table Name"))
        self.table.setHorizontalHeaderItem(1, QTableWidgetItem("Covers"))
        self.table.setHorizontalHeaderItem(2, QTableWidgetItem("Edit"))
        self.table.setHorizontalHeaderItem(3, QTableWidgetItem("Delete"))

        # self.table.insertRow(self.table.rowCount())
        #
        # self.table.setItem(self.table.rowCount() - 1, 0, QTableWidgetItem("ID1"))
        # self.table.setItem(self.table.rowCount() - 1, 1, QTableWidgetItem("Name1"))
        # self.table.setItem(self.table.rowCount() - 1, 2, QTableWidgetItem("Job1"))
        # self.table.setItem(self.table.rowCount() - 1, 3, QTableWidgetItem("Joining Date1"))
        # self.table.setItem(self.table.rowCount() - 1, 4, QTableWidgetItem("Salary1"))
        # self.table.setItem(self.table.rowCount() - 1, 5, QTableWidgetItem("Bonus1"))
        # self.table.setItem(self.table.rowCount() - 1, 6, QTableWidgetItem("Total Salary1"))
        # self.table.setItem(self.table.rowCount() - 1, 7, QTableWidgetItem("Edit1"))
        # self.table.setItem(self.table.rowCount() - 1, 8, QTableWidgetItem("Delete1"))

        data = self.load_tables_data()
        print(data)

        for x in data:
            print(x)

        self.populate_table(data)

        layout = QVBoxLayout()

        layout.addWidget(header)
        layout.addWidget(add_and_search)
        layout.addWidget(self.table)
        # layout.addStretch()
        layout.addWidget(footer)

        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)

        centralWidget = QWidget()
        centralWidget.setLayout(layout)

        self.setCentralWidget(centralWidget)
        self.setContentsMargins(0, 0, 0, 0)

        # self.resize(800, 600)
        self.setWindowTitle("Login")
        self.resize(1160, 605)

        self.show()
        self.center()
Exemplo n.º 11
0
    def initUI(self):

        in_class = "orders"

        self.sidebar = sidebar.Sidebar(self)
        self.sidebar.window.connect(self.getvalue)

        self.addDockWidget(Qt.LeftDockWidgetArea, self.sidebar)

        header = AppName(in_class)
        footer = Footer()

        self.scrollArea = QScrollArea()
        # self.scrollArea.setContentsMargins(0, 0, 0, 0)
        self.scrollArea.setStyleSheet("Border: none")

        left_content = QVBoxLayout(self.scrollArea)
        left_content.setContentsMargins(0, 0, 0, 0)
        left_content.setSpacing(0)

        table = QLabel("Table No")

        table_list = self.get_tables()

        self.table_no = QComboBox()
        self.table_no.setFixedWidth(250)
        self.table_no.addItems(table_list)

        hl = QHBoxLayout()
        hl.addStretch()
        hl.addWidget(table)
        hl.addStretch()
        hl.addWidget(self.table_no)
        hl.addStretch()

        # left_content.addLayout(hlayout1)
        left_content.addLayout(hl)

        menu_list = self.get_menu_items()

        for key, value in menu_list.items():
            if value:
                category = QLabel(key)
                category.setAlignment(Qt.AlignCenter)

                left_content.addWidget(category)

                for x in value:
                    quantity = QLineEdit()
                    quantity.setFixedWidth(50)
                    quantity.setFixedHeight(50)

                    xtimes = QLabel(" X ")

                    widget2 = MenuItems(x)
                    widget2.setMouseTracking(True)
                    widget2.mouseMoveEvent = functools.partial(self.mouse_moved, source_object=widget2)
                    widget2.leaveEvent = functools.partial(self.mouse_left, source_object=widget2)
                    widget2.mousePressEvent = functools.partial(self.mouse_pressed,
                                                                source_object=[quantity, widget2])
                    widget2.setStyleSheet("background-color: grey; color: black")

                    hlayout2 = QHBoxLayout()
                    hlayout2.setContentsMargins(10, 10, 0, 0)
                    hlayout2.addWidget(quantity)
                    hlayout2.addWidget(xtimes)
                    hlayout2.addWidget(widget2)

                    # widget2.mousePressEvent = functools.partial(self.mouse_pressed, source_object=hlayout2)

                    left_content.addLayout(hlayout2)
                    left_content.addStretch()

        # left_content.addLayout(hlayout2)



        # self.thumbnail = QHBoxLayout()
        # self.scrollArea.setMaximumWidth(self.width()/2)

        self.scrollChildArea = QWidget()
        self.scrollChildArea.setLayout(left_content)

        self.scrollArea.setWidgetResizable(True)
        self.scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        # self.scrollArea.setMinimumHeight(160)
        # self.scrollArea.setMaximumHeight(160)
        self.scrollArea.setWidget(self.scrollChildArea)
        # self.scrollArea.setFrameShape(QFrame().NoFrame)
        self.scrollArea.setStatusTip("Preview")

        # ---------------------------------------------------
        self.scrollArea2 = QScrollArea()
        # self.scrollArea2.setContentsMargins(0, 0, 0, 0)
        self.scrollArea2.setStyleSheet("Border: none")
        # ---------------------------------------------------

        self.right_content = QVBoxLayout(self.scrollArea2)
        self.right_content.setContentsMargins(0, 0, 0, 0)
        # self.right_content.setAlignment(Qt.AlignCenter)

        # ---------------------------------------------------
        self.scrollChildArea2 = QWidget()
        self.scrollChildArea2.setLayout(self.right_content)

        self.scrollArea2.setWidgetResizable(True)
        self.scrollArea2.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.scrollArea2.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        # self.scrollArea2.setMinimumHeight(160)
        # self.scrollArea2.setMaximumHeight(160)
        self.scrollArea2.setWidget(self.scrollChildArea2)
        # self.scrollArea2.setFrameShape(QFrame().NoFrame)
        self.scrollArea2.setStatusTip("Preview")
        bar = self.scrollArea2.verticalScrollBar()
        bar.rangeChanged.connect(lambda: bar.setValue(bar.maximum()))
        # ---------------------------------------------------

        bill = QLabel()
        bill.setText("Bill")
        bill.setAlignment(Qt.AlignCenter)
        bill.setFixedWidth(450)
        bill.setStyleSheet("font: 75 20pt \"MS Shell Dlg 2\";")

        self.msg = QLabel("")
        self.msg.setFixedHeight(50)

        print_bill = QPushButton("Send")
        print_bill.setFixedWidth(100)
        print_bill.setFixedHeight(50)
        print_bill.setStyleSheet("font: 75 12pt \"MS Shell Dlg 2\";\n"
                                 "background-color: rgb(30, 45, 66);\n"
                                 "color: rgb(255, 255, 255);")
        print_bill.clicked.connect(self.send_bill)

        hl2 = QHBoxLayout()
        hl2.addWidget(self.msg, alignment=Qt.AlignCenter)
        hl2.addWidget(print_bill, alignment=Qt.AlignRight)

        self.total = 0.00
        self.food_order = []

        self.total_amount = QLabel("Total : " + str(self.total))
        self.total_amount.setAlignment(Qt.AlignRight)


        self.right_content.addWidget(bill)
        self.right_content.addStretch()
        self.right_content.addWidget(self.total_amount)
        self.right_content.addLayout(hl2)
        self.right_content.addStretch()

        content = QGridLayout()
        content.setContentsMargins(0, 0, 0, 0)
        content.setSpacing(0)

        content.addWidget(self.scrollArea, 0, 0)
        content.addWidget(self.scrollArea2, 0, 1)


        layout = QVBoxLayout()

        layout.addWidget(header)
        layout.addLayout(content)
        layout.addStretch()
        layout.addWidget(footer)

        layout.setContentsMargins(0, 0, 0, 0)

        centralWidget = QWidget()
        centralWidget.setLayout(layout)

        self.setCentralWidget(centralWidget)
        self.setContentsMargins(0, 0, 0, 0)



        self.setWindowTitle("Settings")
        self.resize(1160, 605)

        self.show()
        self.center()
Exemplo n.º 12
0
    def initUI(self):

        in_class = "settings"

        self.sidebar = sidebar.Sidebar(self)
        self.sidebar.window.connect(self.getvalue)

        self.addDockWidget(Qt.LeftDockWidgetArea, self.sidebar)

        header = AppName(in_class)
        footer = Footer()

        change_passwordbtn = QPushButton("Change Password")
        change_passwordbtn.setStyleSheet("background-color: rgb(30, 45, 66);\n"
                                         "font: 75 12pt \"MS Shell Dlg 2\";\n"
                                         "color: rgb(255, 255, 255);")
        change_passwordbtn.setFixedWidth(170)
        change_passwordbtn.setFixedHeight(40)
        change_passwordbtn.clicked.connect(self.change_password)

        add_userbtn = QPushButton("Add User")
        add_userbtn.setStyleSheet("background-color: rgb(30, 45, 66);\n"
                                  "font: 75 12pt \"MS Shell Dlg 2\";\n"
                                  "color: rgb(255, 255, 255);")
        add_userbtn.setFixedWidth(170)
        add_userbtn.setFixedHeight(40)
        add_userbtn.clicked.connect(self.add_user)

        edit_restaurant_label = QLabel("Edit Restaurant Information")
        edit_restaurant_label.setStyleSheet(
            "color: rgb(30, 45, 66);\n"
            "font: 75 20pt \"MS Shell Dlg 2\";")

        restaurantlabel = QLabel()
        restaurantlabel.setText("Name")
        restaurantlabel.setGeometry(QRect(80, 100, 47, 13))
        restaurantlabel.setFixedWidth(190)
        restaurantlabel.setFixedHeight(40)
        restaurantlabel.setStyleSheet("color: rgb(30, 45, 66);\n"
                                      'font: 75 18pt "MS Shell Dlg 2";')

        self.restauranttextbox = QLineEdit()
        self.restauranttextbox.setGeometry(QRect(160, 90, 181, 31))
        self.restauranttextbox.setFixedWidth(280)
        self.restauranttextbox.setFixedHeight(40)

        addresslabel = QLabel()
        addresslabel.setText("Job Title")
        addresslabel.setGeometry(QRect(80, 140, 61, 16))
        addresslabel.setFixedWidth(190)
        addresslabel.setFixedHeight(40)
        addresslabel.setStyleSheet("color: rgb(30, 45, 66);\n"
                                   'font: 75 18pt "MS Shell Dlg 2";')

        self.addresstextbox = QLineEdit()
        self.addresstextbox.setGeometry(QRect(160, 130, 181, 31))
        self.addresstextbox.setFixedWidth(280)
        self.addresstextbox.setFixedHeight(40)

        contact = QLabel()
        contact.setText("Salary")
        contact.setGeometry(QRect(80, 180, 47, 13))
        contact.setFixedWidth(190)
        contact.setFixedHeight(40)
        contact.setStyleSheet("color: rgb(30, 45, 66);\n"
                              'font: 75 18pt "MS Shell Dlg 2";')

        self.contacttextbox = QLineEdit()
        self.contacttextbox.setGeometry(QRect(160, 170, 181, 31))
        self.contacttextbox.setFixedWidth(280)
        self.contacttextbox.setFixedHeight(40)
        self.contacttextbox.setValidator(QIntValidator())

        update_btn = QPushButton("Update")
        update_btn.setGeometry(QRect(370, 500, 131, 41))
        update_btn.setStyleSheet("background-color: rgb(30, 45, 66);\n"
                                 "font: 75 12pt \"MS Shell Dlg 2\";\n"
                                 "color: rgb(255, 255, 255);")
        update_btn.setFixedWidth(130)
        update_btn.setFixedHeight(40)
        update_btn.clicked.connect(self.update_data)

        self.load_data()

        hlayout1 = QHBoxLayout()
        hlayout1.addStretch()
        hlayout1.addWidget(change_passwordbtn)
        hlayout1.addWidget(add_userbtn)
        hlayout1.addStretch()

        hlayout2 = QHBoxLayout()
        hlayout2.addStretch()
        hlayout2.addWidget(edit_restaurant_label)
        hlayout2.addStretch()

        hlayout3 = QHBoxLayout()
        hlayout3.addStretch()
        hlayout3.addWidget(restaurantlabel)
        hlayout3.addWidget(self.restauranttextbox)
        hlayout3.addStretch()

        hlayout4 = QHBoxLayout()
        hlayout4.addStretch()
        hlayout4.addWidget(addresslabel)
        hlayout4.addWidget(self.addresstextbox)
        hlayout4.addStretch()

        hlayout5 = QHBoxLayout()
        hlayout5.addStretch()
        hlayout5.addWidget(contact)
        hlayout5.addWidget(self.contacttextbox)
        hlayout5.addStretch()

        hlayout6 = QHBoxLayout()
        hlayout6.addStretch()
        hlayout6.addWidget(update_btn)
        hlayout6.addStretch()

        layout = QVBoxLayout()

        layout.addWidget(header)
        layout.addLayout(hlayout1)
        layout.addStretch()
        layout.addLayout(hlayout2)
        layout.addLayout(hlayout3)
        layout.addLayout(hlayout4)
        layout.addLayout(hlayout5)
        layout.addLayout(hlayout6)
        layout.addStretch()
        layout.addStretch()
        layout.addWidget(footer)

        layout.setContentsMargins(0, 0, 0, 0)

        centralWidget = QWidget()
        centralWidget.setLayout(layout)

        self.setCentralWidget(centralWidget)
        self.setContentsMargins(0, 0, 0, 0)

        self.setWindowTitle("Settings")
        self.resize(1160, 605)

        self.show()
        self.center()