python - My QGridLayout in PyQt doesn't show all elements, or in the right places -


when @ mainwindow in qt designer, see mainwindow

however, when compile ui file python code, take match object (a qgroupbox "champion" title, inside match history), , port on can build many of these things , add them scroll area (match history) , run thisbad mainwindow

the group box ends shortly after bottom of window, doesn't go on forever, , have confirmed in code width , height of group box set correctly. i've confirmed match object indeed have 10 slots , has items in after being built, problem doesn't right @ runtime. what's going wrong?

here buildmatch method:

def buildmatch(self, summonerid, matchindex, matchid, matchwidth, matchheight):     # method takes matchindex , matchid input, builds match object, , returns it. part of      # building each match object, method calls calculatematchstatistics() , calculateaverages. might      # prudent later call self.calculateaverages() once, rather every time, i'm not sure.     # globals: none      # check whether have match data matchid in question. if do,      # continue. if not, call getmatchdetails match , store data in matchhistorydetails.     # keys of matchhistorydetails dictionary unicode strings. convert matchid unicode      # before using key or lookup element.     matchid = unicode(matchid)     knownmatchids = self.matchhistorydetails.keys()     if matchid not in knownmatchids:         self.matchhistorydetails[matchid] = self.getmatchdetails(summonerid, matchid)      # load champion name getchampionname() , lane matchhistorylist     championid = self.matchhistorylist["matches"][matchindex]["champion"]     championname = self.getchampionname(championid)      match = qgroupbox(championname)     match.setfixedheight(matchwidth)     match.setfixedwidth(matchheight)      matchwidget = qwidget(match)     matchwidget.setgeometry(qrect(10, 20, matchwidth, matchheight))     matchlayout = qgridlayout(matchwidget)      statisticsboxtomatchwidthratio = .165     statisticsboxtomatchheightratio = .3895     statisticsboxwidth = int(matchwidth * statisticsboxtomatchwidthratio)     statisticsboxheight = int(matchheight * statisticsboxtomatchheightratio)      scorebox = qgroupbox(matchwidget)     scorebox.setalignment(qt.aligncenter)     scorebox.settitle("score")     scorebox.setstylesheet('qgroupbox {font: 8pt "calibri"}')     scorebox.settooltip("score, in format of kills-deaths-assists")     scorevalue = qlabel(scorebox)     scorevalue.setgeometry(qrect(10, 29, statisticsboxwidth, statisticsboxheight))     scorevalue.setalignment(qt.aligncenter)     scorevalue.setstylesheet('font: 9pt "calibri";')      kdabox = qgroupbox(matchwidget)     kdabox.setalignment(qt.aligncenter)     kdabox.settitle("kda")     kdabox.setstylesheet('qgroupbox {font: 8pt "calibri"}')     kdabox.settooltip("calculated (kills+deaths)/assists")     kdavalue = qlabel(kdabox)     kdavalue.setgeometry(qrect(10, 29, statisticsboxwidth, statisticsboxheight))     kdavalue.setalignment(qt.aligncenter)      killparticipationpercentbox = qgroupbox(matchwidget)     killparticipationpercentbox.setalignment(qt.aligncenter)     killparticipationpercentbox.settitle("kill part. %")     killparticipationpercentbox.setstylesheet('qgroupbox {font: 8pt "calibri"}')     killparticipationpercentbox.settooltip("the percentage of teams kills contributed to")     killparticipationpercentvalue = qlabel(killparticipationpercentbox)     killparticipationpercentvalue.setgeometry(qrect(10, 29, statisticsboxwidth, statisticsboxheight))     killparticipationpercentvalue.setalignment(qt.aligncenter)      goldperminbox = qgroupbox(matchwidget)     goldperminbox.setalignment(qt.aligncenter)     goldperminbox.settitle("gold/min")     goldperminbox.setstylesheet('qgroupbox {font: 8pt "calibri"}')     goldperminbox.settooltip("gold earned per minute")     goldperminvalue = qlabel(goldperminbox)     goldperminvalue.setgeometry(qrect(11, 29, statisticsboxwidth, statisticsboxheight))     goldperminvalue.setalignment(qt.aligncenter)      wardscorebox = qgroupbox(matchwidget)     wardscorebox.setalignment(qt.aligncenter)     wardscorebox.settitle("ward score")     wardscorebox.setstylesheet('qgroupbox {font: 8pt "calibri"}')     wardscorebox.settooltip("calculated wards placed + wards killed")     wardscorevalue = qlabel(wardscorebox)     wardscorevalue.setgeometry(qrect(10, 30, statisticsboxwidth, statisticsboxheight))     wardscorevalue.setalignment(qt.aligncenter)      csperminbox = qgroupbox(matchwidget)     csperminbox.setalignment(qt.aligncenter)     csperminbox.settitle("cs/min")     csperminbox.setstylesheet('qgroupbox {font: 8pt "calibri"}')     csperminbox.settooltip("creeps killed per minute")     csperminvalue = qlabel(csperminbox)     csperminvalue.setgeometry(qrect(10, 29, statisticsboxwidth, statisticsboxheight))     csperminvalue.setalignment(qt.aligncenter)      spaceritem2 = qspaceritem(40, 20, qsizepolicy.expanding, qsizepolicy.minimum)      lanelabel = qlabel(matchwidget)     lanelabel.setalignment(qt.aligncenter)     lanelabel.setstylesheet('font: 10pt "calibri";')     lanelabel.settooltip("lane")      spaceritem3 = qspaceritem(40, 20, qsizepolicy.expanding, qsizepolicy.minimum)      resultlabel = qlabel(matchwidget)     resultlabel.setalignment(qt.aligncenter)     resultlabel.setstylesheet('font: 12pt "calibri"')     resultlabel.settooltip("match result")      matchlayout.additem(spaceritem2, 0, 1, 1, 1)     matchlayout.addwidget(scorebox, 0, 2, 1, 1)     matchlayout.addwidget(killparticipationpercentbox, 0, 3, 1, 1)     matchlayout.addwidget(wardscorebox, 0, 4, 1, 1)     matchlayout.additem(spaceritem3, 0, 5, 1, 1)     matchlayout.addwidget(resultlabel, 0, 6, 1, 1)     matchlayout.addwidget(lanelabel, 1, 0, 1, 1)     matchlayout.addwidget(kdabox, 1, 2, 1, 1)     matchlayout.addwidget(goldperminbox, 1, 3, 1, 1)     matchlayout.addwidget(csperminbox, 1, 4, 1, 1)      matchlayout.setcolumnstretch(0, 10)     matchlayout.setcolumnstretch(1, 3)     matchlayout.setcolumnstretch(2, 11)     matchlayout.setcolumnstretch(3, 10)     matchlayout.setcolumnstretch(4, 10)     matchlayout.setcolumnstretch(5, 3)     matchlayout.setcolumnstretch(6, 10)     matchlayout.setrowstretch(0, 10)     matchlayout.setrowstretch(1, 10)      ##################################################      # set values each item     matchwon = self.matchhistorystatistics["matches"][matchid]["won"]     if matchwon:         result = "win"     else:         result = "loss"     score = self.matchhistorystatistics["matches"][matchid]["score"]     kda = self.matchhistorystatistics["matches"][matchid]["kda"]     kdaaverage = self.matchhistorystatistics["kdaaverage"]     killparticipationpercent = self.matchhistorystatistics["matches"][matchid]["killparticipationpercent"]     killparticipationpercentaverage = self.matchhistorystatistics["killparticipationpercentaverage"]     wardscore = self.matchhistorystatistics["matches"][matchid]["wardscore"]     wardscoreaverage = self.matchhistorystatistics["wardscoreaverage"]     goldpermin = self.matchhistorystatistics["matches"][matchid]["goldpermin"]     goldperminaverage = self.matchhistorystatistics["goldperminaverage"]     cspermin = self.matchhistorystatistics["matches"][matchid]["cspermin"]     csperminaverage = self.matchhistorystatistics["csperminaverage"]     lane = self.matchhistorylist["matches"][matchindex]["lane"].lower().capitalize()     if lane == "bottom":         lane = "bot"      resultlabel.settext(result)     scorevalue.settext(str(score))     kdavalue.settext(str(kda))     killparticipationpercentvalue.settext(str(killparticipationpercent))     wardscorevalue.settext(str(wardscore))     goldperminvalue.settext(str(goldpermin))     csperminvalue.settext(str(cspermin))     lanelabel.settext(lane)      if result == "win":         resultlabel.setstylesheet('color: green; font: 12pt "calibri";')     else:         resultlabel.setstylesheet('color: red; font: 12pt "calibri";')     if kda > kdaaverage:         kdavalue.setstylesheet('color: green; font: 9pt "calibri";')     else:         kdavalue.setstylesheet('color: red; font: 9pt "calibri";')     if killparticipationpercent > killparticipationpercentaverage:         killparticipationpercentvalue.setstylesheet('color: green; font: 9pt "calibri";')     else:         killparticipationpercentvalue.setstylesheet('color: red; font: 9pt "calibri";')     if wardscore > wardscoreaverage:         wardscorevalue.setstylesheet('color: green; font: 9pt "calibri";')     else:         wardscorevalue.setstylesheet('color: red; font: 9pt "calibri";')     if goldpermin > goldperminaverage:         goldperminvalue.setstylesheet('color: green; font: 9pt "calibri";')     else:         goldperminvalue.setstylesheet('color: red; font: 9pt "calibri";')     if cspermin > csperminaverage:         csperminvalue.setstylesheet('color: green; font: 9pt "calibri";')     else:         csperminvalue.setstylesheet('color: red; font: 9pt "calibri";')      return match 


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -