Python Forum
[PyQt] cant import progress bar from another py file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] cant import progress bar from another py file
#6
Star 
I think I figured out why it is not drawing. In main.py file I set a grid (self.grid = QtGui.QGridLayout(self) and then self.grid.addWidget(self.myprogressbar, 1, 0)) and now my progress bar is on screen :)

[Image: EIYTW] (image of progress bar)

Now question is why I cant set progress bar size in main.py file by using setgeometry?
self.myprogressbar.setGeometry(10, 10, 50, 50)
here is the progress bar code:
class cPrg(QtGui.QWidget):
    def __init__(self, initialValue=0, parent=None):
        super(cPrg, self).__init__(parent)
        self.textas = 'bandom'
        self.lineWidth = 0
        self.startAngle = 0
        self.endAngle = 0
        self.setValue(initialValue)

    def setValue(self, val):
        val = float(min(max(val, 0), 1))
        self._value = -270 * val
        self.update()

    def setLineWidth(self, lineWidth):
        self.lineWidth = lineWidth

    def paintEvent(self, e):
        painter = QtGui.QPainter(self)
        painter.setRenderHint(painter.Antialiasing)
        rect = e.rect()
        outerRadius = min(self.width(), self.height())
        
        r = QtCore.QRectF(.5,.5,outerRadius-20,outerRadius-20)                            #<-- create rectangle

        startAngle = 270 * 16  # <-- set start angle to draw arc
        endAngle = -270 * 16  # <-- set end arc angle

        painter.setPen(QPen(QtGui.QColor('#000000'), 3))#self.lineWidth))  # <-- arc color
        # painter.setBrush(QtCore.Qt.HorPattern)
        painter.drawArc(r, startAngle, endAngle)  # <-- draw arc

        # arc prg
        painter.save()
        painter.setPen(QPen(QtGui.QColor('#ffffff'), 10))
        painter.drawArc(r, startAngle, self._value * 16)
        painter.restore()

        painter.end()
        super(cPrg, self).paintEvent(e)
Reply


Messages In This Thread
RE: cant import progress bar from another py file - by swipis - Dec-18-2016, 10:05 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Import a file and show file name on qcombobox GMCobraz 1 2,008 Jul-02-2020, 01:38 PM
Last Post: GMCobraz
  [PyQt] Import Excel file and use pandas WBPYTHON 2 5,759 Mar-22-2020, 11:28 AM
Last Post: WBPYTHON
  How can I measure progress and display it in the progress bar in the interface? Matgaret 2 5,997 Dec-11-2019, 03:30 PM
Last Post: Denni
  [Tkinter] Progress Bar While Sending an Email maxtimbo 3 4,180 Oct-09-2019, 09:13 PM
Last Post: woooee
  Progress Bar While Sending an Email maxtimbo 0 2,149 Oct-08-2019, 02:13 PM
Last Post: maxtimbo
  GUI Progress Bar Anysja 6 6,687 Aug-29-2018, 02:34 PM
Last Post: swetanjali
  PyQt5 - import rext from other file - despearte for help D_frucht 1 2,523 May-26-2018, 06:37 AM
Last Post: Barrowman

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020