Skip to main content

Navigation bar expansion package based on PyQt5 and PySide2.(x64 bit os only)

Project description

GNavbar is an expansion package based on PyQt5 (PySide2). It can be used to create navigation bars on the windows generated by PyQt5 (PySide2). It can save time for users to manually set the navigation bar. It also supports self-designed navigation bar styles to make the window more beautiful. At the same time, GNavbar also supports unlimited nesting!

This version is the first release of the GNavbar module, and the previous version is a beta version.

Supported Platforms

Operating system: Windows x64 bit >= 8.1 , Other OS have not been tested

Python: Python >= 3.10

Others: PyQt5 or PySide2 (Currently, other versions of Qt for Python are not supported)

Author

Mr. LAOGUObest, a young programmer from the earth.

Installation

GNavbar can be installed from PyPI

pip install GNavbar

If the download speed in your region is too slow, you can use the mirror station as follows

pip install -i [URL of the mirror station] GNavbar

Support from GNavbar package

If you want to get help and some information about your GNavbar package, you can enter the following code in the Python editor

import GNavbar
GNavbar.help()

Similarly, we can enter the following code to start the demo window program in GNavbar.

GNavbar.run()

Expected Updates (v1.0→v1.1)

1 . Navigation bar centering function will be added.

2 . The function of customized navigation bar will be improved.

Simple usage

This is a simple example of using GNavbar, but the final effect is very ugly. Because the code is really too simple.

import sys
#Several modules here are replaced by '*'.
try:
    from PyQt5.QtCore import *
    from PyQt5.QtGui import *
    from PyQt5.QtWidgets import *
except ImportError:
    from PySide2.QtCore import *
    from PySide2.QtGui import *
    from PySide2.QtWidgets import *
from GNavbar import *

class Demo(QFrame):
    def __init__(self):
        super(Demo,self).__init__()
        self.resize(494, 300)
        #Create a Navigation Bar.
        self.n = GNavbar(self)
        #Add items to the navigation bar and set the size of the items.
        self.n.addNavbar(100,50)
        #Set text for navigation bar items.
        self.n.setNavbarText(i=0,text='First GNavbar')
        #Set the page corresponding to the navigation bar item.
        self.n.setPage(0,self.page1)
        #Set the grid layout so that the navigation bar is rolled out to the entire window.
        self.gridLayout = QGridLayout(self)
        self.gridLayout.setObjectName(u"gridLayout")
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.gridLayout.addWidget(self.n, 0, 0, 0, 0)
        QMetaObject.connectSlotsByName(self)
        self.setWindowTitle("GNavbar DemoWindow")
    def page1(self,frame):
        #Specific contents of the corresponding page of the navigation bar.
        self.pushButton = QPushButton(frame)
        self.pushButton.setObjectName(u"pushButton")
        self.pushButton.setGeometry(QRect(0, 0, 100, 100))
        self.pushButton.setText("Hello GNavbar")

if __name__ == "__main__":
    #run
    app = QApplication(sys.argv)
    demo = Demo()
    demo.show()
    sys.exit(app.exec())

The previous example is the simplest way to use it.

Add Style

We can add some “meat and blood” to make it look beautiful, as in the following example. The default navigation bar in GNavbar is the left navigation bar. If you don’t like the left navigation bar, you can change it to the right, top, or bottom navigation bar with the following code.

self.n.setLeft()
self.n.setRight()
self.n.setTop()
self.n.setBottom()

We can also set the StyleSheet for the navigation bar. These style sheets do not inherit to the page corresponding to the navigation bar item. They only work on the navigation bar.In this way, we can set the style on the navigation bar with confidence and boldness, without worrying about other content being affected by it.

self.n.setStyleSheet(u"background-color: rgb(40,40,150);")

If you don’t like setting the style sheet to achieve the background color, you can set the background color, the selected color and the foreground color by setting the theme color.

#Note: The colors here only support the form of ‘qRgb()’.
self.n.setColor(qRgb(40,40,150),qRgb(100,100,250),qRgb(255,255,255))

Next, we set the spacing between adjacent navigation bar items. The default value in GNavbar is no gap. It can make the navigation bar more beautiful.

#Set spacing to 10.
self.n.setSpacing(10)

If you want to set more fonts, there are two ways for you to choose. You can set the font of the entire navigation bar; You can also set the font of a navigation bar item.

#Set the font of navigation bar.
self.n.setFont(size=15,bold=True,font='Microsoft YaHei UI')
#Set the font of a navigation bar item,Set fonts when setting text.
self.n.setNavbarText(self,i=0,text='First GNavbar',size=15,bold=True,font='Microsoft YaHei UI')

Of course, there are more methods for style setting, which are listed below.

#Note:All 'i', 'index', 'width', 'height' and 'size' are integer.
#Set the horizontal and vertical distance between two adjacent items on the navigation bar.
self.n.setGrid(width,height)
#Set the size of navigation bar items.
self.n.setNavbarSize(i,width,height)
#Set horizontal alignment for all text on the navigation bar,The default is horizontal center alignment.
self.n.AutoTextCenter()
self.n.AutoTextLeft()
self.n.AutoTextRight()
#Set icon for navigation bar item.
self.n.setNavbarIcon(i,icon,size)
#Delete navigation bar Item.
self.n.deleteNavbar(i)
#Set the background color of navigation bar item,Color is limited to qRgb.
self.n.setNavbarColor(i,color)
#Set to automatically determine the size of the navigation bar according to the window size,where 'w' and 'h' are multiples of window width and height.
self.n.setAutoSize(w,h)
#Sets the fixed size of the navigation bar. This method has the opposite effect to setAutoSize().
self.n.setSize(width,height)
#Set the mode of the navigation bar to icon mode.
self.n.setIconMode()
#Set the mode of the navigation bar to list mode.
self.n.setListMode()
#Force navigation bar refresh
self.n.u()
#Switch the page corresponding to the navigation bar.
self.n.change(index)
#Set whether to open the navigation bar box border,only bool value.
self.n.box(tf)
#Set the content of the navigation bar item to synchronize to its page.
self.n.setFlowFrame(i)
#Delete Page Synchronization.
self.n.delFlow(i)
#Set custom navigation bar item.
self.n.setOwnNavbar(i,widget)

This is all the content of this version of GNavbar. How about it? Is it easy to use? Is it powerful? I believe you can use it to make beautiful window programs! Let’s work together!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

GNavbar-1.0.221019.tar.gz (188.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

GNavbar-1.0.221019-py3-none-any.whl (188.0 kB view details)

Uploaded Python 3

File details

Details for the file GNavbar-1.0.221019.tar.gz.

File metadata

  • Download URL: GNavbar-1.0.221019.tar.gz
  • Upload date:
  • Size: 188.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for GNavbar-1.0.221019.tar.gz
Algorithm Hash digest
SHA256 7074e40199ca9735117c8f26aa6af175ba6809cd0b68cf572c842ecb72b44afc
MD5 e912f714a6fea93254347749f2e94f9c
BLAKE2b-256 eec9d81cc7a9ae96c0d7791d3ce4221ef148dddd068ae1bcfce2b7901648f12f

See more details on using hashes here.

File details

Details for the file GNavbar-1.0.221019-py3-none-any.whl.

File metadata

  • Download URL: GNavbar-1.0.221019-py3-none-any.whl
  • Upload date:
  • Size: 188.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for GNavbar-1.0.221019-py3-none-any.whl
Algorithm Hash digest
SHA256 e3db7a467cf9fdf8b79c62c5f3c1cc5aab1bca69328d519e0016e3d32a2204aa
MD5 f132bb0414d2f286c976b7e640f53a00
BLAKE2b-256 c721539b9ea395cfcc270d4460167857b01503f0cc4c8edf51806ce2e6465869

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page