Questions in relation to properties fields and code structure.
[email protected] Mon, 15 May 2023 20:10:50 +1000
| Newsgroups | gmane.comp.python.wxglade |
|---|---|
| Message-ID | <[email protected]> |
This is a multipart message in MIME format.
--===============6746049542746333397==
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_007F_01D98769.599F53B0"
Content-Language: en-au
This is a multipart message in MIME format.
------=_NextPart_000_007F_01D98769.599F53B0
Content-Type: text/plain;
charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
All,
=20
I have only just started to use Version 1.0.4 on Python 3.10.11 and =
wxPython 4.2.0. I am a screen reader user, some of these questions might =
be in the images in the wx / WXGlade documentation. If this is the case, =
please except my apology now. Images cannot be described by my screen =
reader.=20
=20
I am building a library book program for myself to learn WX and python. =
No plans at this stage to publish the program as it is for my own use. =
The GUI structure is:=20
* The first 3 pages (panels) are have the same layout.
* Treeview on the left side of the screen.=20
* Right hand side at the top is a search field.
* Right hand side underneath the search is a listview.
I am trying to work out when to use Instance, Class / base class. As =
each of the panels will have different data populated in them and not =
sure the best approach. As being new to programming, I am seeking =
guidance.
=20
The following class is for the Title panel. My thoughts is this class =
could be a super class (I think that is the correct term) where Title, =
Authors and Genres (the names of the 3 pages) would use the same class. =
Then reference the class structure to populate the information. =
Otherwise is it better to have three classes holding the same layout =
code?
=20
class MyTitlePanel(ViewRecordPanel):
def __init__(self, *args, **kwds):
# begin wxGlade: MyTitlePanel.__init__
kwds["style"] =3D kwds.get("style", 0) | wx.TAB_TRAVERSAL
# I defined a base class, not sure what a Base class means within =
WXGlade. I suspect I would have to create a class. If so, do I use the =
MyTitlePanel as the template?
ViewRecordPanel.__init__(self, *args, **kwds)
sizer_1 =3D wx.BoxSizer(wx.HORIZONTAL)
self.tree_ctrl_1 =3D wx.TreeCtrl(self, wx.ID_ANY)
sizer_1.Add(self.tree_ctrl_1, 1, wx.EXPAND, 0)
sizer_6 =3D wx.BoxSizer(wx.VERTICAL)
sizer_1.Add(sizer_6, 1, wx.EXPAND, 0)
sizer_8 =3D wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, =
"Search"), wx.HORIZONTAL)
sizer_6.Add(sizer_8, 1, wx.EXPAND, 0)
label_1 =3D wx.StaticText(self, wx.ID_ANY, "Search")
sizer_8.Add(label_1, 0, 0, 0)
self.text_ctrl_1 =3D wx.TextCtrl(self, wx.ID_ANY, "")
sizer_8.Add(self.text_ctrl_1, 0, 0, 0)
self.button_1 =3D wx.Button(self, wx.ID_FIND, "")
sizer_8.Add(self.button_1, 0, 0, 0)
sizer_7 =3D wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, =
"Results"), wx.VERTICAL)
sizer_6.Add(sizer_7, 1, wx.EXPAND, 0)
self.list_ctrl_1 =3D wx.ListCtrl(self, wx.ID_ANY, =
style=3Dwx.LC_HRULES | wx.LC_REPORT | wx.LC_VRULES)
self.list_ctrl_1.AppendColumn("Titles", =
format=3Dwx.LIST_FORMAT_LEFT, width=3D-1)
self.list_ctrl_1.AppendColumn("B", format=3Dwx.LIST_FORMAT_LEFT, =
width=3D-1)
self.list_ctrl_1.AppendColumn("C", format=3Dwx.LIST_FORMAT_LEFT, =
width=3D-1)
self.list_ctrl_1.AppendColumn("Authors", =
format=3Dwx.LIST_FORMAT_LEFT, width=3D-1)
self.list_ctrl_1.AppendColumn("Genres", =
format=3Dwx.LIST_FORMAT_LEFT, width=3D-1)
self.list_ctrl_1.AppendColumn("Series", =
format=3Dwx.LIST_FORMAT_LEFT, width=3D-1)
self.list_ctrl_1.AppendColumn("Series Number", =
format=3Dwx.LIST_FORMAT_LEFT, width=3D-1)
sizer_7.Add(self.list_ctrl_1, 1, wx.EXPAND, 0)
self.SetSizer(sizer_1)
self.Layout()
# end wxGlade
=20
# below is the main frame.
class LibraryFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: LibraryFrame.__init__
kwds["style"] =3D kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.SetSize((400, 300))
self.SetTitle("Book Library")
self.notebook_1 =3D wx.Notebook(self, wx.ID_ANY)
# the next lines assigns the MyTitlePanel class=20
self.notebook_1_pane_1 =3D MyTitlePanel(self.notebook_1, =
wx.ID_ANY)
self.notebook_1.AddPage(self.notebook_1_pane_1, "Titles")
# below is how the instance is being created. I assume I would =
have to create the class like was done for MyTitlePanel class?
self.notebook_1_pane_2 =3D MyAuthorsPanel(self.notebook_1, =
wx.ID_ANY)
self.notebook_1.AddPage(self.notebook_1_pane_2, "Authors")
the remaining code in this class is a repeat of each panel showing the =
same widget using the same layout.=20
=20
When you inform WXGlade to use a class and then define a base class. How =
do you reference the code for the base class assuming you have to create =
it? Could a base class be the same layout structure as I indicated with =
myTitlePanel? The documentation doesn=E2=80=99t relay explain this.
=20
Finally, I see focus option for majority of the widgets / panels / etc. =
Is this for keyboard focus handling? If you turn on the focus option, is =
it changing anything visually? As I have used the calculator sample code =
and it accessed all the widgets. So I am confused of the purpose of the =
property.
=20
I am hoping someone can help.
=20
Note: I am not a solid OOPS programmer and there is a lot of terminology =
I just don=E2=80=99t get yet. =F0=9F=98=8A
=20
Sean=20
------=_NextPart_000_007F_01D98769.599F53B0
Content-Type: text/html;
charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dutf-8">
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns=3D"http://www.w3.org/TR/REC-html40"><head><meta name=3DGenerator =
content=3D"Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-ligatures:standardcontextual;
mso-fareast-language:EN-US;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-ligatures:standardcontextual;
mso-fareast-language:EN-US;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:1542858179;
mso-list-type:hybrid;
mso-list-template-ids:-312946242 -1650714938 201916419 201916421 =
201916417 201916419 201916421 201916417 201916419 201916421;}
@list l0:level1
{mso-level-start-at:0;
mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Symbol;
mso-fareast-font-family:Calibri;
mso-bidi-font-family:"Times New Roman";}
@list l0:level2
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Courier New";}
@list l0:level3
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Wingdings;}
@list l0:level4
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Symbol;}
@list l0:level5
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Courier New";}
@list l0:level6
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Wingdings;}
@list l0:level7
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Symbol;}
@list l0:level8
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Courier New";}
@list l0:level9
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Wingdings;}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]--></head><body lang=3DEN-AU =
link=3D"#0563C1" vlink=3D"#954F72" style=3D'word-wrap:break-word'><div =
class=3DWordSection1><p class=3DMsoNormal>All,<o:p></o:p></p><p =
class=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNormal>I have only =
just started to use Version 1.0.4 on Python 3.10.11 and wxPython 4.2.0. =
I am a screen reader user, some of these questions might be in the =
images in the wx / WXGlade documentation. If this is the case, please =
except my apology now. Images cannot be described by my screen reader. =
<o:p></o:p></p><p class=3DMsoNormal><o:p> </o:p></p><p =
class=3DMsoNormal>I am building a library book program for myself to =
learn WX and python. No plans at this stage to publish the program as it =
is for my own use. The GUI structure is: <o:p></o:p></p><ul =
style=3D'margin-top:0cm' type=3Ddisc><li class=3DMsoListParagraph =
style=3D'margin-left:0cm;mso-list:l0 level1 lfo1'>The first 3 pages =
(panels) are have the same layout.<o:p></o:p></li><li =
class=3DMsoListParagraph style=3D'margin-left:0cm;mso-list:l0 level1 =
lfo1'>Treeview on the left side of the screen. <o:p></o:p></li><li =
class=3DMsoListParagraph style=3D'margin-left:0cm;mso-list:l0 level1 =
lfo1'>Right hand side at the top is a search field.<o:p></o:p></li><li =
class=3DMsoListParagraph style=3D'margin-left:0cm;mso-list:l0 level1 =
lfo1'>Right hand side underneath the search is a =
listview.<o:p></o:p></li></ul><p class=3DMsoNormal>I am trying to work =
out when to use Instance, Class / base class. As each of the panels will =
have different data populated in them and not sure the best approach. As =
being new to programming, I am seeking guidance.<o:p></o:p></p><p =
class=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNormal>The =
following class is for the Title panel. My thoughts is this class could =
be a super class (I think that is the correct term) where Title, Authors =
and Genres (the names of the 3 pages) would use the same class. Then =
reference the class structure to populate the information. Otherwise is =
it better to have three classes holding the same layout =
code?<o:p></o:p></p><p class=3DMsoNormal><o:p> </o:p></p><p =
class=3DMsoNormal>class MyTitlePanel(ViewRecordPanel):<o:p></o:p></p><p =
class=3DMsoNormal> def __init__(self, *args, =
**kwds):<o:p></o:p></p><p =
class=3DMsoNormal> # begin =
wxGlade: MyTitlePanel.__init__<o:p></o:p></p><p =
class=3DMsoNormal> =
kwds["style"] =3D kwds.get("style", 0) | =
wx.TAB_TRAVERSAL<o:p></o:p></p><p class=3DMsoNormal># I defined a base =
class, not sure what a Base class means within WXGlade. I suspect I =
would have to create a class. If so, do I use the MyTitlePanel as =
the template?<o:p></o:p></p><p =
class=3DMsoNormal> =
ViewRecordPanel.__init__(self, *args, **kwds)<o:p></o:p></p><p =
class=3DMsoNormal> sizer_1 =3D =
wx.BoxSizer(wx.HORIZONTAL)<o:p></o:p></p><p =
class=3DMsoNormal> =
self.tree_ctrl_1 =3D wx.TreeCtrl(self, wx.ID_ANY)<o:p></o:p></p><p =
class=3DMsoNormal> =
sizer_1.Add(self.tree_ctrl_1, =
1, wx.EXPAND, 0)<o:p></o:p></p><p =
class=3DMsoNormal> sizer_6 =3D =
wx.BoxSizer(wx.VERTICAL)<o:p></o:p></p><p =
class=3DMsoNormal> =
sizer_1.Add(sizer_6, 1, wx.EXPAND, 0)<o:p></o:p></p><p =
class=3DMsoNormal> sizer_8 =3D =
wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Search"), =
wx.HORIZONTAL)<o:p></o:p></p><p =
class=3DMsoNormal> =
sizer_6.Add(sizer_8, 1, wx.EXPAND, 0)<o:p></o:p></p><p =
class=3DMsoNormal> label_1 =3D =
wx.StaticText(self, wx.ID_ANY, "Search")<o:p></o:p></p><p =
class=3DMsoNormal> =
sizer_8.Add(label_1, 0, 0, 0)<o:p></o:p></p><p =
class=3DMsoNormal> =
self.text_ctrl_1 =3D wx.TextCtrl(self, wx.ID_ANY, =
"")<o:p></o:p></p><p =
class=3DMsoNormal> =
sizer_8.Add(self.text_ctrl_1, 0, 0, 0)<o:p></o:p></p><p =
class=3DMsoNormal> =
self.button_1 =3D wx.Button(self, wx.ID_FIND, =
"")<o:p></o:p></p><p =
class=3DMsoNormal> =
sizer_8.Add(self.button_1, 0, 0, 0)<o:p></o:p></p><p =
class=3DMsoNormal> sizer_7 =3D =
wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Results"), =
wx.VERTICAL)<o:p></o:p></p><p =
class=3DMsoNormal> =
sizer_6.Add(sizer_7, 1, wx.EXPAND, 0)<o:p></o:p></p><p =
class=3DMsoNormal> =
self.list_ctrl_1 =3D wx.ListCtrl(self, wx.ID_ANY, style=3Dwx.LC_HRULES | =
wx.LC_REPORT | wx.LC_VRULES)<o:p></o:p></p><p =
class=3DMsoNormal> =
self.list_ctrl_1.AppendColumn("Titles", =
format=3Dwx.LIST_FORMAT_LEFT, width=3D-1)<o:p></o:p></p><p =
class=3DMsoNormal> =
self.list_ctrl_1.AppendColumn("B", =
format=3Dwx.LIST_FORMAT_LEFT, width=3D-1)<o:p></o:p></p><p =
class=3DMsoNormal> =
self.list_ctrl_1.AppendColumn("C", =
format=3Dwx.LIST_FORMAT_LEFT, width=3D-1)<o:p></o:p></p><p =
class=3DMsoNormal> =
self.list_ctrl_1.AppendColumn("Authors", =
format=3Dwx.LIST_FORMAT_LEFT, width=3D-1)<o:p></o:p></p><p =
class=3DMsoNormal> =
self.list_ctrl_1.AppendColumn("Genres", =
format=3Dwx.LIST_FORMAT_LEFT, width=3D-1)<o:p></o:p></p><p =
class=3DMsoNormal> =
self.list_ctrl_1.AppendColumn("Series", =
format=3Dwx.LIST_FORMAT_LEFT, width=3D-1)<o:p></o:p></p><p =
class=3DMsoNormal> =
self.list_ctrl_1.AppendColumn("Series Number", =
format=3Dwx.LIST_FORMAT_LEFT, width=3D-1)<o:p></o:p></p><p =
class=3DMsoNormal> =
sizer_7.Add(self.list_ctrl_1, 1, wx.EXPAND, 0)<o:p></o:p></p><p =
class=3DMsoNormal> =
self.SetSizer(sizer_1)<o:p></o:p></p><p =
class=3DMsoNormal> =
self.Layout()<o:p></o:p></p><p =
class=3DMsoNormal> # end =
wxGlade<o:p></o:p></p><p class=3DMsoNormal><o:p> </o:p></p><p =
class=3DMsoNormal># below is the main frame.<o:p></o:p></p><p =
class=3DMsoNormal>class LibraryFrame(wx.Frame):<o:p></o:p></p><p =
class=3DMsoNormal> def __init__(self, *args, =
**kwds):<o:p></o:p></p><p =
class=3DMsoNormal> # begin =
wxGlade: LibraryFrame.__init__<o:p></o:p></p><p =
class=3DMsoNormal> =
kwds["style"] =3D kwds.get("style", 0) | =
wx.DEFAULT_FRAME_STYLE<o:p></o:p></p><p =
class=3DMsoNormal> =
wx.Frame.__init__(self, *args, **kwds)<o:p></o:p></p><p =
class=3DMsoNormal> =
self.SetSize((400, 300))<o:p></o:p></p><p =
class=3DMsoNormal> =
self.SetTitle("Book Library")<o:p></o:p></p><p =
class=3DMsoNormal> =
self.notebook_1 =3D wx.Notebook(self, wx.ID_ANY)<o:p></o:p></p><p =
class=3DMsoNormal> # the next =
lines assigns the MyTitlePanel class <o:p></o:p></p><p =
class=3DMsoNormal> self.no=
tebook_1_pane_1 =3D MyTitlePanel(self.notebook_1, =
wx.ID_ANY)<o:p></o:p></p><p =
class=3DMsoNormal> =
self.notebook_1.AddPage(self.notebook_1_pane_1, =
"Titles")<o:p></o:p></p><p =
class=3DMsoNormal> # below is =
how the instance is being created. I assume I would have to create the =
class like was done for MyTitlePanel class?<o:p></o:p></p><p =
class=3DMsoNormal> =
self.notebook_1_pane_2 =3D MyAuthorsPanel(self.notebook_1, =
wx.ID_ANY)<o:p></o:p></p><p =
class=3DMsoNormal> =
self.notebook_1.AddPage(self.notebook_1_pane_2, =
"Authors")<o:p></o:p></p><p class=3DMsoNormal>the remaining =
code in this class is a repeat of each panel showing the same widget =
using the same layout. <o:p></o:p></p><p =
class=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNormal>When you =
inform WXGlade to use a class and then define a base class. How do you =
reference the code for the base class assuming you have to create it? =
Could a base class be the same layout structure as I indicated with =
myTitlePanel? The documentation doesn=E2=80=99t relay explain =
this.<o:p></o:p></p><p class=3DMsoNormal><o:p> </o:p></p><p =
class=3DMsoNormal>Finally, I see focus option for majority of the =
widgets / panels / etc. Is this for keyboard focus handling? If you turn =
on the focus option, is it changing anything visually? As I have used =
the calculator sample code and it accessed all the widgets. So I am =
confused of the purpose of the property.<o:p></o:p></p><p =
class=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNormal>I am hoping =
someone can help.<o:p></o:p></p><p =
class=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNormal>Note: I am =
not a solid OOPS programmer and there is a lot of terminology I just =
don=E2=80=99t get yet. <span style=3D'font-family:"Segoe UI =
Emoji",sans-serif'>=F0=9F=98=8A</span><o:p></o:p></p><p =
class=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNormal>Sean =
<o:p></o:p></p></div></body></html>
------=_NextPart_000_007F_01D98769.599F53B0--
--===============6746049542746333397==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
--===============6746049542746333397==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
wxGlade-general mailing list
wxGlade-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/wxglade-general
--===============6746049542746333397==--