473,387 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

wxGlade and __init__

I'm making a GUI for a console-based program I just wrote. I figured
it would be mostly straight forward to convert it over in wxPython but
now I'm confused.

In my console program, I have __init__ making the dictionaries et al.
and then my methods will populate them. However, when I use wxGlade
under SPE to make the GUI, wxGlade makes it's own __init__. I know not
to add anything to this section because it's written over everytime I
make changes in wxGlade.

How do I reconcile having the auto created __init__ from wxGlade and
the __init__ I want to use from my console version?

Here's an example of my console program:

def __init__(self):
"""Constructor to initialize each data member to zero."""

#---Attribute info
self.attrib = 0
self.attrib_dict = self.default_attribs.copy() #instance
version
self.setAttribute("str")
self.setAttribute("intel")
self.setAttribute("build")
self.setAttribute("char")
self.setAttribute("will")
self.setAttribute("throw")
self.setAttribute("mass")
self.setAttribute("load")
self.setAttribute("dex")
self.coreInitiative = 0

#---Create attributes---
def setAttribute(self, attr):
"""Generate value for an attribute, between 2 and 20."""

#---Get secondary attributes
if attr == "throw":
self.attrib_dict[attr] = self.attrib_dict["str"] * 2
#meters
elif attr == "mass":
self.attrib_dict[attr] = (self.attrib_dict["build"] * 5) +
15 #kg
elif attr == "load":
self.attrib_dict[attr] = (self.attrib_dict["str"] +
self.attrib_dict["build"]) #kg
#---Get core attributes
else:
self.attrib_dict[attr] = multiDie(2, 2) #2d10

Here's the code created by wxGlade:

class Attributes(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: Attributes.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.panel_2 = wx.Panel(self, -1)
self.btnAttributes = wx.Button(self.panel_2, -1, "Get
Attributes")
self.lblAge = wx.StaticText(self.panel_2, -1, "Age:")
self.txtAge = wx.TextCtrl(self.panel_2, -1, "")
self.lblChar = wx.StaticText(self.panel_2, -1, "Charisma:")
self.txtChar = wx.TextCtrl(self.panel_2, -1, "")
self.lblStr = wx.StaticText(self.panel_2, -1, "Strength:")
self.txtStr = wx.TextCtrl(self.panel_2, -1, "")
self.lblBuild = wx.StaticText(self.panel_2, -1, "Build:")
self.txtBuild = wx.TextCtrl(self.panel_2, -1, "")
self.lblIntel = wx.StaticText(self.panel_2, -1,
"Intelligence:")
self.txtIntel = wx.TextCtrl(self.panel_2, -1, "")
self.lblThrow = wx.StaticText(self.panel_2, -1, "Throw Range:")
self.txtThrow = wx.TextCtrl(self.panel_2, -1, "")
self.lblWill = wx.StaticText(self.panel_2, -1, "Willpower:")
self.txtWill = wx.TextCtrl(self.panel_2, -1, "")
self.lblMass = wx.StaticText(self.panel_2, -1, "Mass:")
self.txtMass = wx.TextCtrl(self.panel_2, -1, "")
self.lblDex = wx.StaticText(self.panel_2, -1, "Dexterity:")
self.txtDex = wx.TextCtrl(self.panel_2, -1, "")
self.lblLoad = wx.StaticText(self.panel_2, -1, "Load:")
self.txtLoad = wx.TextCtrl(self.panel_2, -1, "")
self.lblHP = wx.StaticText(self.panel_2, -1, "Hit Points")
self.lblHead = wx.StaticText(self.panel_2, -1, "Head:")
self.txtHead = wx.TextCtrl(self.panel_2, -1, "")
self.lblTorso = wx.StaticText(self.panel_2, -1, "Torso:")
self.txtTorso = wx.TextCtrl(self.panel_2, -1, "")
self.lblRArm = wx.StaticText(self.panel_2, -1, "Right Arm:")
self.txtRArm = wx.TextCtrl(self.panel_2, -1, "")
self.lblLArm = wx.StaticText(self.panel_2, -1, "Left Arm:")
self.txtLArm = wx.TextCtrl(self.panel_2, -1, "")
self.lblRLeg = wx.StaticText(self.panel_2, -1, "Right Leg:")
self.txtRLeg = wx.TextCtrl(self.panel_2, -1, "")
self.lblLLeg = wx.StaticText(self.panel_2, -1, "Left Leg:")
self.text_ctrl_18 = wx.TextCtrl(self.panel_2, -1, "")
self.btnNext2 = wx.Button(self.panel_2, -1, "Next Page")

self.__set_properties()
self.__do_layout()
# end wxGlade

Aug 26 '06 #1
2 1661

crystalattice wrote:
I'm making a GUI for a console-based program I just wrote. I figured
it would be mostly straight forward to convert it over in wxPython but
now I'm confused.
Hi Crystalattice,

One thing you could do is make your original console-program a subclass
of the wxGlade-generated GUI.

Another thing you could do is to keep the original console program code
intact, and to make the GUI program create an instance of your original
console program, and call it.

You can modify to some extent the code generated by wxGlade, or you can
subclass it (which is what I do, following advice found on this list).

Good luck,

--Tim

Aug 26 '06 #2
Tim N. van der Leeuw wrote:
crystalattice wrote:
I'm making a GUI for a console-based program I just wrote. I figured
it would be mostly straight forward to convert it over in wxPython but
now I'm confused.

Hi Crystalattice,

One thing you could do is make your original console-program a subclass
of the wxGlade-generated GUI.

Another thing you could do is to keep the original console program code
intact, and to make the GUI program create an instance of your original
console program, and call it.

You can modify to some extent the code generated by wxGlade, or you can
subclass it (which is what I do, following advice found on this list).

Good luck,

--Tim
I think I get it. I'll mess with it and see what happens. Thanks.

Aug 27 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Donald 'Paddy' McCarthy | last post by:
Hi, I am having a few problems with a GUI. I am new to traits and wxGlade. I have used wxGlade to create a Form with an embedded space for a CustomWidget. I have the traits demo and would like...
2
by: Pilu | last post by:
hi,given that I'm a newbie in python, I have a little problem with wx... Maybe it's a stupid thing,but if u want help me! I used wxglade to generate a simple window with a button! wxglade...
1
by: Somesh Bartakkay | last post by:
i installed wxGlade on System xp, when i started it ..its not running ?
0
by: LenS | last post by:
I have installed wxGlade on a MS XP machine. It executed on completion of the install. However, when I try to double click on the wxGlade icon to start nothing happens. I searched the NG and...
2
by: physci | last post by:
I've been combing google for the past week trying to find an appropriate set of tools for a project I'm working on. Simply put, what I need is a GUI, powered by python, (I really don't want to...
7
by: diffuser78 | last post by:
I recently tried a hand at wxGlade and was happy to see it designs a GUI for you in minutes. I am a newbie Python coder. I am not completely aware of GUI programming. I can easily make menubars...
9
by: agsupriya86 | last post by:
How to add keyboard event to a button in wxglade??
3
by: Steve Holden | last post by:
I've been trying to use wxGlade recently and I am finding it something of a challenge. Is there any user who finds the user interface satisfactory and the operation of the program predictable? ...
10
by: exodus | last post by:
As a fun little task to gain more knowledge of python, i decided to try to mimick the ipod UI with it. here's what i've got so far #!/usr/bin/env python # -*- coding: utf-8 -*- # generated by...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.