Python Forum
[WxPython] NameError: global name 'PyAssertionError' is not defined
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[WxPython] NameError: global name 'PyAssertionError' is not defined
#6
Thanks a lot, Yoritz!

With this, it works :-) .
( I wish the wypython docs would give hints to those kind of things, but I can search and search and search and never come across things like that... *sigh*)

And, well, as I have spend (wasted) time in it, the code... if ever somebody would be interested how to get such an error in an easy way.

import wx, wx.grid

class Teilgridpanel(wx.Panel):
    def __init__(self, parent, id):
        wx.Panel.__init__(self, parent, id,
                         pos = wx.DefaultPosition,
                         size = wx.DefaultSize,
                         style = wx.TAB_TRAVERSAL|wx.NO_BORDER)

        self.gridsize = gridsize = (1, 5)

        self.grid = wx.grid.Grid(self, style=wx.BORDER_SUNKEN)
        self.grid.CreateGrid(gridsize[0], gridsize[1])
        for dyn in range(6):
            dystri = "x"

            try:
                self.grid.SetCellValue(0, dyn, dystri)
            except PyAssertionError:
                print "wrong row or column"



class Mainframe(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title)

        # und das Datenpanel in seinem BoxSizer
        self.datenpanel = Teilgridpanel(self, wx.ID_ANY)

        self.dpbox = dpbox = wx.BoxSizer(wx.HORIZONTAL) 
        dpbox.Add(self.datenpanel, 1, wx.EXPAND)

        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add(dpbox, 1, wx.EXPAND)
        self.SetSizerAndFit(hbox)


if __name__ == "__main__": 

    app = wx.App(0)
    
    mainframe = Mainframe(None, -1, "Mainframe")   
    app.MainLoop() 
Reply


Messages In This Thread
RE: NameError: global name 'PyAssertionError' is not defined - by merlem - Jan-28-2017, 01:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  NameError: name 'self' is not defined hobbyist 30 14,838 Jul-25-2021, 10:22 AM
Last Post: hobbyist
  [Kivy] NameError: name 'App' is not defined nengkya 4 13,703 Apr-02-2017, 07:15 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

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