wx.RadioButon Problem

schwedenmann

schwedenmann

Foren Gott
Hallo

Warum sind in dem Beispiel die Radiuobuttons nicht sichtbar ?

Code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
# spinctrl.py
 
import wx
class MyDialog(wx.Dialog):
    def __init__(self, parent, id, title):
        wx.Dialog.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(350, 310))
        wx.StaticText(self, -1, 'Bitte wählen sie aus', (200,1))
        self.SetBackgroundColour('Green')
        
        pnl = wx.Panel(self)
        
        self.rb1 = wx.RadioButton(pnl, label='Zinseszins', pos=(10, 5), 
            style=wx.RB_GROUP)
        self.rb2 = wx.RadioButton(pnl, label='Darlehn', pos=(10, 35))
        self.rb3 = wx.RadioButton(pnl, label='Renten C', pos=(10, 65))
        
        self.rb1.Bind(wx.EVT_RADIOBUTTON, self.SetVal)
        self.rb2.Bind(wx.EVT_RADIOBUTTON, self.SetVal)
        self.rb3.Bind(wx.EVT_RADIOBUTTON, self.SetVal)
        
        
        
    
        
        clear_btn = wx.Button(self, 1, 'Beenden', (185, 250))
 
        self.Bind(wx.EVT_BUTTON, self.OnClose, id=1)
        self.Bind(wx.EVT_CLOSE, self.OnClose)
 
    def OnClose(self, event):
         self.Destroy()
    
    def SetVal(self, e):
        
        state1 = str(self.rb1.GetValue())
        state2 = str(self.rb2.GetValue())
        state3 = str(self.rb3.GetValue())     
         
     
 
class MyApp(wx.App):
    def OnInit(self):
         dlg = MyDialog(None, -1, 'Zinseszins.py')
         dlg.Show(True)
         dlg.Centre()
         return True
 
app = MyApp(0)
app.MainLoop()


Ja ich weiß, mit sizern wäre das Ganze besser, ist aber nur mein Anfang mit wx.Python, aber es sollte prinzipiell doch auch so (ohne sizer + abolute Positionen) gehen.
Das Ganze soll später mal ein Finanz-mathe-Rechner (Zinbseszins, Renten,Darlehn + plotten) werden. Mit den RadioButtons wollte ich später 2x jeweils einen neuen frame aufrufen.

mfg
schwedenmann
 
Zuletzt bearbeitet von einem Moderator:
Es wäre schön, wenn du du Code mit dem entsprechenden Tag formatieren könntest.
Ich musste zum Testen alle Einrückungen manuell nachtippen.

Bei mir sieht die Schose aus, wie im Anhang.
Ist Ich nehme an, dass die Ausdehnung der Grundfläche der Radiobuttons spezifiziert werden muss und sonst auf einen Minimalwert (s. Bild) standardisiert.

MfG

Schard

PS: So gehts:
Code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
# spinctrl.py

import wx

class MyDialog(wx.Dialog):
	def __init__(self, parent, id, title):
		wx.Dialog.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(350, 310))
		wx.StaticText(self, -1, 'Bitte wählen sie aus', (200,1))
		self.SetBackgroundColour('Green')

[B]		pnl = wx.Panel(self, id, wx.DefaultPosition, wx.Size(150,150))[/B]

		self.rb1 = wx.RadioButton(pnl, label='Zinseszins', pos=(10, 5),
		style=wx.RB_GROUP)
		self.rb2 = wx.RadioButton(pnl, label='Darlehn', pos=(10, 35))
		self.rb3 = wx.RadioButton(pnl, label='Renten C', pos=(10, 65))
		
		self.rb1.Bind(wx.EVT_RADIOBUTTON, self.SetVal)
		self.rb2.Bind(wx.EVT_RADIOBUTTON, self.SetVal)
		self.rb3.Bind(wx.EVT_RADIOBUTTON, self.SetVal)





		clear_btn = wx.Button(self, 1, 'Beenden', (185, 250))

		self.Bind(wx.EVT_BUTTON, self.OnClose, id=1)
		self.Bind(wx.EVT_CLOSE, self.OnClose)

	def OnClose(self, event):
		self.Destroy()

	def SetVal(self, e):
		state1 = str(self.rb1.GetValue())
		state2 = str(self.rb2.GetValue())
		state3 = str(self.rb3.GetValue())



class MyApp(wx.App):
	def OnInit(self):
		dlg = MyDialog(None, -1, 'Zinseszins.py')
		dlg.Show(True)
		dlg.Centre()
		return True

app = MyApp(0)
app.MainLoop()
 

Anhänge

  • Bildschirmfoto vom 2013-02-16 20:37:01.png
    Bildschirmfoto vom 2013-02-16 20:37:01.png
    6,4 KB · Aufrufe: 10
Zuletzt bearbeitet von einem Moderator:

Ähnliche Themen

wxPython Problem

Displayport + externer Monitor zeigt bei startx nichts erst bei DVI

dovecot und postfix Konfiguration Problem

Ubuntu X / dbus problem

datei bei upload umbenennen

Zurück
Oben