Edit frame doesn't fit to parent size

Torsten Bronger bronger at physik.rwth-aachen.de
Mon Dec 4 05:18:44 PST 2006


Hallöchen!

Please have a look at the attached more or less minimal example.  It
loads a text file to an STC editor frame in the top frame.  On
Linux, this works perfectly, however, on Windows, the Editor windows
remains tiny until the top frame is resized.  Why is this?

Thank you!

Tschö,
Torsten.


--8<---------------cut here---------------start------------->8---
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import wx, wx.py.editor, wx.py.editwindow
import os, sys

class Editor(wx.py.editor.EditWindow):
    def __init__(self, parent):
        wx.stc.StyledTextCtrl.__init__(self, parent, wx.ID_ANY)

class Frame(wx.Frame):
    def __init__(self, *args, **keyw):
        wx.Frame.__init__(self, None, wx.ID_ANY, size=(700, 700), title="Felo", *args, **keyw)
        menu_bar = wx.MenuBar()

        menu_file = wx.Menu()
        open = menu_file.Append(wx.ID_ANY, u"&Open")
        self.Bind(wx.EVT_MENU, self.OnOpen, open)
        menu_bar.Append(menu_file, u"&File")

        self.SetMenuBar(menu_bar)

        self.filename = self.editor = None
    def open_file(self, filename):
        self.filename = os.path.abspath(filename)
        if not self.editor:
            self.editor = Editor(self)
        self.editor.LoadFile(self.filename)
    def OnOpen(self, event):
        wildcard = u"Felo files (*.felo)|*.felo|" \
            "All Files (*.*)|*.*"
        dialog = wx.FileDialog(None, u"Choose file", os.getcwd(),
                               "", wildcard, wx.OPEN | wx.FILE_MUST_EXIST)
        if dialog.ShowModal() == wx.ID_OK:
            self.open_file(dialog.GetPath())
            dialog.Destroy()

class App(wx.App):
    def OnInit(self):
        self.frame = Frame()
        self.frame.Show()
        self.SetTopWindow(self.frame)
        return True

app = App()
app.MainLoop()
--8<---------------cut here---------------end--------------->8---


-- 
Torsten Bronger, aquisgrana, europa vetus
                                                    ICQ 264-296-646
                   (See http://ime.webhop.org for Jabber, MSN, etc.)





More information about the wxpython-users mailing list