
na dann eine neue Frage

LG,
fanus

Hallo fanus!fanus hat geschrieben:gibts bei wxFrame eine Möglichkeit, sie "Modal" zu benutzen so, dass beim Öffnen die anderen Fenster blokiert werden? halt wie .ShowModal() bei Dialogen...
Code: Alles auswählen
import wx
import wx.grid
class MyGrid(wx.Frame) :
def __init__(self):
wx.Frame.__init__(self, None, title = "a simple grid", size = (330,200))
self.rowLabels = ["1", "2", "3"]
self.colLabels = ["a", "b", "c"]
self.grid = wx.grid.Grid(self)
self.grid.CreateGrid(3, 3)
for row in range(3):
self.grid.SetRowLabelValue(row, self.rowLabels[row])
self.grid.SetColLabelValue(row, self.colLabels[row])
for col in range(3):
self.grid.SetCellValue(row, col, "%s" % "CellValue")
Code: Alles auswählen
from Grid import MyGrid
class MyFrame(wx.Frame):
...
def OnOpenGrid(self, event):
MyGrid().MakeModal()
MyGrid().Show()
Code: Alles auswählen
#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
import wx
wx.SetDefaultPyEncoding("iso-8859-15")
class MyModalFrame(wx.Frame):
def __init__(self, parent, title = "Modal Frame", size = wx.Size(500, 600)):
wx.Frame.__init__(self, parent, -1, title, size = size)
panel = wx.Panel(self)
panel.SetBackgroundColour("green")
self.MakeModal(True)
self.Bind(wx.EVT_CLOSE, self.on_close)
def on_close(self, event = None):
self.MakeModal(False)
event.Skip()
class MyMainFrame(wx.Frame):
def __init__(
self, parent = None, title = "Example", size = wx.Size(350, 220)
):
wx.Frame.__init__(self, parent, -1, title, size = size)
panel = wx.Panel(self)
vbox_main = wx.BoxSizer(wx.VERTICAL)
panel.SetSizer(vbox_main)
vbox_main.AddStretchSpacer()
btn_modalframe = wx.Button(panel, label = u"Modales Frame anzeigen")
btn_modalframe.Bind(wx.EVT_BUTTON, self.show_modal_frame)
vbox_main.Add(btn_modalframe, 0, wx.CENTER)
vbox_main.AddStretchSpacer()
def show_modal_frame(self, event = None):
self.modal_frame = MyModalFrame(self)
self.modal_frame.Show()
def main():
"""Testing"""
app = wx.PySimpleApp()
f = MyMainFrame()
f.Center()
f.Show()
app.MainLoop()
if __name__ == "__main__":
main()