Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4267648
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:55:41+00:00 2026-05-21T06:55:41+00:00

Not sure if I am asking this correctly (e.g. using widget/object in the correct

  • 0

Not sure if I am asking this correctly (e.g. using widget/object in the correct context). This code is meant just as an experiment (learning about classes and wxPython right now) – so it might not make sense as functional code.

Problem: I have a window/frame that I am allowing the user to specify width/height, and there is a multiline text box that is nested inside the window/frame. Originally, I was setting the dimensions of the multiline text box to the same size of the parent frame, but the scroll bar was being hidden because the scroll bar of the text box is larger than the frame/text box size. So… I decided to just manually adjust the size of the text box to make sure the size of the text box accounted for the scroll bar (see code below, specifically lines “sizexTxt = sizex – 17” and “sizeyTxt = sizey – 44”).

Question: Is there some sort of way for adjusting the text box other than manually adjusting pixel by pixel? Is there a suggestion someone can offer that would be considered pythonic?

import wx

class myFrame(wx.Frame):
      def __init__(self, parent, title, sizexy, sizexyTxt):
          wx.Frame.__init__(self, parent, title=title, size=sizexy)
          self.Show(True)
          wx.TextCtrl(self, style=wx.TE_MULTILINE, size=(sizexyTxt))
          pass

sizex = input("X= ")
sizey = input("Y= ")
sizexy=(sizex, sizey)

sizexTxt = sizex - 17
sizeyTxt = sizey - 44
sizexyTxt = (sizexTxt, sizeyTxt)

myApp = wx.App(False)
frameNow = myFrame(None,"This is my title", sizexy, sizexyTxt)
myApp.MainLoop()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T06:55:42+00:00Added an answer on May 21, 2026 at 6:55 am

    Jake pointed you in a right direction, but there is one more thing. You should be aware that first object which goes into the frame is wrapped into the basic sizer. The problem is that as far as I know you have no control of this sizer. So you have to add your own sizer, which you can use for frame fitting. You need the control over the sizer, because you would like the frame to change its size according to sizer.

    import wx
    
    class myFrame(wx.Frame):
        def __init__(self, size, *arg, **kwarg):
            wx.Frame.__init__(self, *arg, **kwarg)
            self.text = wx.TextCtrl(self, style=wx.TE_MULTILINE, size=size)
    
            self.sizer = wx.BoxSizer()
            self.sizer.Add(self.text, proportion=1, flag=wx.EXPAND)
            self.SetSizerAndFit(self.sizer)
    
            self.Show()
    
    
    myApp = wx.App(False)
    
    size = []
    for a in ["X", "Y"]:
        d = wx.NumberEntryDialog(None, "Text size", "%s: " % a, "Window size entry", 100, 50, 200)
        if d.ShowModal() == wx.ID_OK:
            size.append(d.GetValue())
    
    frameNow = myFrame(size, None)
    myApp.MainLoop()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not sure if I'm even asking this question correctly. I just built my
Not sure if I am asking this correctly. But I am using a Jquery
I am new to C# and not sure if I'm asking this correctly. I
Not sure if I am asking this correctly (i am new to EF). Basically
I'm not sure whether I'm asking the question correctly, but I've been told SQL
Not sure if this is possible or if I'm expressing correctly what I'm looking
I'm not sure that I'm using the correct language here so I will give
I'll exemplify, since I'm not sure if I'm asking the question correctly (English is
I'm not sure I'm asking the right question here, but I'm looking to provide
Not sure how to ask a followup on SO, but this is in reference

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.