**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

.. code:: python

   import GNavbar
   GNavbar.help()

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

.. code:: python

   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.

.. code:: python

   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.

.. code:: python

   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.

.. code:: python

   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.

.. code:: python

   #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.

.. code:: python

   #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.

.. code:: python

   #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.

.. code:: python

   #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!
