error with radio buttons in popup window

In my app, I tryed to design a popup window withe radio buttons, but this error was raised " radio button outside of TLW" when I put style=wx.RB_GROUP.
I used wx.PopupWindow for the popup window.

any help would be appreciated.

Thanks

also I tried wx.PopupTransientWindow and still have the same error.

Show us the code. We don't have crystal balls.

···

a.m.n.alsubhi@gmail.com wrote:

In my app, I tryed to design a popup window withe radio buttons, but
this error was raised " radio button outside of TLW" when I put
style=wx.RB_GROUP.
I used wx.PopupWindow for the popup window.

any help would be appreciated.

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

“Here is the class of the popup window:”

class controlPanel(wx.PopupTransientWindow):#

def init( self, parent,style,Title,word,position):

wx.PopupTransientWindow.init(self, parent,style)

	pnl = wx.Panel(self, -1)

#panel = wx.Panel(self)

#self.panel=panel

	bSizer1 = wx.BoxSizer( wx.VERTICAL )

	f = self.GetFont()

dc = wx.WindowDC(pnl)

dc.SetFont(f)

	m_staticText1 = wx.StaticText( pnl, wx.ID_ANY, Title, wx.DefaultPosition, wx.DefaultSize, 0 )

	m_staticText1.SetFont( wx.Font( wx.NORMAL_FONT.GetPointSize(), 70, 90, 92, False, wx.EmptyString ) )

	bSizer1.Add(m_staticText1, 0, wx.ALL, 5 )

	myHSizer1 = wx.BoxSizer(wx.HORIZONTAL)

m_radioBtn1 = wx.RadioButton( pnl, id=wx.ID_ANY, label=" ", pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.RB_GROUP)

	myHSizer1.Add( m_radioBtn1, 0, wx.ALL, 5 )

m_staticText3 = wx.StaticText( pnl, wx.ID_ANY, u"Opstion1", wx.DefaultPosition, wx.DefaultSize, 0 )

width, height = dc.GetTextExtent(“Option1”)

m_staticText3.Wrap(width)

myHSizer1.Add( m_staticText3, 0, wx.ALL, 5 )

	 bSizer1.Add( myHSizer1)

	  myHSizer2 = wx.BoxSizer(wx.HORIZONTAL)

m_radioBtn2 = wx.RadioButton( pnl , id=wx.ID_ANY, label=" ", pos=wx.DefaultPosition, size=wx.DefaultSize)

	  myHSizer2.Add( m_radioBtn2, 0, wx.ALL, 5 )

	  m_staticText4 = wx.StaticText( pnl, wx.ID_ANY, u"Option2:", wx.DefaultPosition, wx.DefaultSize, 0 )

width, height = dc.GetTextExtent(“Option2”)

m_staticText4.Wrap(width)

myHSizer2.Add( m_staticText4, 0, wx.ALL, 5 )

	   bSizer1.Add( myHSizer2)

m_button1 = wx.Button( pnl , wx.ID_ANY, u"Apply", wx.DefaultPosition, wx.DefaultSize, 0 )

	   bSizer1.Add( m_button1, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 )

	   pnl.SetSizer( bSizer1 )

	   bSizer1.Fit(self)

	   bSizer1.Fit(pnl)

	   self.Layout()

“here is main window of my app:”

class Frame2 ( wx.Frame ):

def init( self, parent,Original_doc,V1_doc,V2_doc , Changes_File ):

wx.Frame.init ( self, parent,id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 1200,650 ), style = wx.DEFAULT_FRAME_STYLE|wx.MAXIMIZE )

" Add some widgets"

if caret in cretin position:

ctrl = controlPanel(self,wx.DOUBLE_BORDER,Title,word,(start,end))

position=self.m_richText4.ClientToScreen(pos)

ctrl.Position(position,(0,0))

ctrl.Popup()

I solved my problem by using wx.dialog instead of popupwindow.

···

On Monday, February 15, 2016 at 6:27:27 PM UTC-5, a.m.n....@gmail.com wrote:

In my app, I tryed to design a popup window withe radio buttons, but this error was raised " radio button outside of TLW" when I put style=wx.RB_GROUP.
I used wx.PopupWindow for the popup window.

any help would be appreciated.

Thanks

my problem was solved by using wx.dialog but it does not meet my need. the idea is if the user double click on specific words the popup window with options (radio buttons) will appeared and if the user clicks any where on the main window the popup window should be disappear. the problem of radio buttons are solved by using wx.dialog, but wx.dialog doesn’t disappear if the user clicks any where on the main window (I add handler for that ).

any suggestions that help me to meet what I want to do would be appreciated.

···

On Tuesday, February 16, 2016 at 7:09:45 PM UTC-5, a.m.n....@gmail.com wrote:

I solved my problem by using wx.dialog instead of popupwindow.

On Monday, February 15, 2016 at 6:27:27 PM UTC-5, a.m.n....@gmail.com wrote:

In my app, I tryed to design a popup window withe radio buttons, but this error was raised " radio button outside of TLW" when I put style=wx.RB_GROUP.
I used wx.PopupWindow for the popup window.

any help would be appreciated.

Thanks

It looks to me like this is simply an unnecessary limitation in the
wxWidgets C++ radio button code. When it goes to set the radio button's
value, it needs to make sure all of the other buttons in the group get
turned off. To do that, it fetches the top-level window containing this
control, then enumerates all of its children to find any sibling radio
buttons.

The code requires by assertion that the top-level window it finds
actually be derived from wxTopLevelWindow. As it turns out,
wxPopupTransientWindow is not derived from wxTopLevelWindow, hence the
error.

There isn't any architectural reason why it has to make that assertion.
I think you could file this as a bug against wxWidgets.

My best suggestion for an alternative is to turn your control panel into
a wx.Panel, then use Show and Hide manage it. You would have to watch
for mouse clicks yourself to know when to hide it.

···

a.m.n.alsubhi@gmail.com wrote:

my problem was solved by using wx.dialog but it does not meet my need.
the idea is if the user double click on specific words the popup
window with options (radio buttons) will appeared and if the user
clicks any where on the main window the popup window should be
disappear. the problem of radio buttons are solved by using wx.dialog,
but wx.dialog doesn't disappear if the user clicks any where on the
main window (I add handler for that ).

any suggestions that help me to meet what I want to do would be
appreciated.

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Thanks Tim for your help.
I tryed wxPopupTransientWindow with radioboxbutton and it works as I want.

···

On Wednesday, February 17, 2016 at 3:12:40 PM UTC-5, Tim Roberts wrote:

a.m.n....@gmail.com wrote:

my problem was solved by using wx.dialog but it does not meet my need.

the idea is if the user double click on specific words the popup

window with options (radio buttons) will appeared and if the user

clicks any where on the main window the popup window should be

disappear. the problem of radio buttons are solved by using wx.dialog,

but wx.dialog doesn’t disappear if the user clicks any where on the

main window (I add handler for that ).

any suggestions that help me to meet what I want to do would be

appreciated.

It looks to me like this is simply an unnecessary limitation in the

wxWidgets C++ radio button code. When it goes to set the radio button’s

value, it needs to make sure all of the other buttons in the group get

turned off. To do that, it fetches the top-level window containing this

control, then enumerates all of its children to find any sibling radio

buttons.

The code requires by assertion that the top-level window it finds

actually be derived from wxTopLevelWindow. As it turns out,

wxPopupTransientWindow is not derived from wxTopLevelWindow, hence the

error.

There isn’t any architectural reason why it has to make that assertion.
I think you could file this as a bug against wxWidgets.

My best suggestion for an alternative is to turn your control panel into

a wx.Panel, then use Show and Hide manage it. You would have to watch

for mouse clicks yourself to know when to hide it.


Tim Roberts, ti...@probo.com

Providenza & Boekelheide, Inc.