Hi all,
I have a problem for which I wasn't able to find an answer anywhere
else, maybe someone can give me a hint...
I designed with XRCed a small GUI (the code is at the bottom of the
message) made up of a menu and a frame in which there are two panels,
placed by an horizontal sizer.
Now, what I would like to do is to be able to load an image and display
it on the left panel, automatically resizing the panel depending on the
image size (the code is at the end again). There are actually two problems:
1) if I load an image the panel is not resized automatically
2) if I resize the panel manually after having loaded the image, the DC
is not repainted. that is, the portion of the image which was invisible
is not painted
Is there anyone with a bit of time to explain me how to solve these
problems?
thanks, qrz
------------------ XRC ----------------------------
<?xml version="1.0" ?>
<resource>
<object class="wxFrame" name="MAIN">
<title>test</title>
<object class="wxBoxSiz er">
<orient>wxHORIZ ONTAL</orient>
<object class="sizerite m">
<object class="wxPanel" name="IMAGE">
<size>100,100 </size>
</object>
<border>5</border>
</object>
<object class="sizerite m">
<object class="wxPanel" name="CONTROLS" >
<size>100,100 </size>
</object>
<border>5</border>
</object>
</object>
</object>
<object class="wxMenuBa r" name="MENU">
<object class="wxMenu" name="MENU_FILE ">
<label>File</label>
<object class="wxMenuIt em" name="MENU_FILE _OPEN">
<label>Open</label>
</object>
</object>
</object>
</resource>
---------------- PYTHON -----------------------------
from wxPython.wx import *
from wxPython.xrc import *
import Image
def pilToWx(pil):
image = wxEmptyImage(pi l.size[0], pil.size[1])
image.SetData(p il.convert('RGB ').tostring())
return image
class MyApp(wxApp):
def OnInit(self):
self.res = wxXmlResource(" test.xrc")
self.InitFrame( )
self.InitMenu()
self.InitEveryt hingElse()
self.image = None
return True
def InitFrame(self) :
self.frame = self.res.LoadFr ame(None, "MAIN")
self.ipanel = XRCCTRL(self.fr ame, "IMAGE")
EVT_PAINT(self. ipanel, self.OnPaint)
self.cpanel = XRCCTRL(self.fr ame, "CONTROLS")
def InitMenu(self):
self.menuBar = self.res.LoadMe nuBar("MENU")
EVT_MENU(self.f rame, XRCID("MENU_FIL E_OPEN"), self.Open)
self.frame.SetM enuBar(self.men uBar)
def InitEverythingE lse(self):
self.sizer = self.frame.GetS izer()
self.frame.SetA utoLayout(True)
self.sizer.Fit( self.frame)
self.sizer.SetS izeHints(self.f rame)
self.frame.Show (1)
self.SetTopWind ow(self.frame)
def Open(self, evt):
fd = wxFileDialog(se lf.frame, "Open image", "", "", \
"PNG image (*.png)|*.png|J PEG image
(*.jpg)|*.jpg", \
wxOPEN)
if fd.ShowModal() == wxID_OK:
im = Image.open(fd.G etPath())
self.image = pilToWx(im)
self.ipanel.Set Size(im.size)
self.ipanel.Ref resh(True)
fd.Destroy()
def OnPaint(self, evt):
if self.image:
dc = wxPaintDC(self. ipanel)
dc.DrawBitmap(s elf.image.Conve rtToBitmap(), 0,0)
def main():
app = MyApp(0)
app.MainLoop()
if __name__ == '__main__':
main() 1 5089
Curzio Basso wrote: Hi all,
I have a problem for which I wasn't able to find an answer anywhere else, maybe someone can give me a hint...
I designed with XRCed a small GUI (the code is at the bottom of the message) made up of a menu and a frame in which there are two panels, placed by an horizontal sizer.
Now, what I would like to do is to be able to load an image and display it on the left panel, automatically resizing the panel depending on the image size (the code is at the end again). There are actually two problems:
1) if I load an image the panel is not resized automatically
2) if I resize the panel manually after having loaded the image, the DC is not repainted. that is, the portion of the image which was invisible is not painted
Is there anyone with a bit of time to explain me how to solve these problems?
thanks, qrz
You probably want to go to the wxPython users mailing list for this (see
the links on the wxpython home page)
David This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ivan Voras |
last post by:
I hava a hierarhical sizer layout in which there's a panel in the upper
part of a window with some buttons, and another panel with wxVListBox
that's meant to occupy all the remaining space in the window. Both
panels are put inside a vertical BoxSizer, and the VListBox in its panel
is also in BoxSizer.
The hierarchy is like this:
- window, vertical BoxSizer
- panel, horizontal BoxSizer
|
by: Adam Endicott |
last post by:
I'm having some trouble using an HtmlListBox with a GridBagSizer. I'm
not sure how best to explain what's happening, but it seems that every
time my frame gets resized, the HtmlListBox grows taller, even when the
resize is only horizontal, or makes the frame smaller. I'm pretty new
to GUI layout and wxPython, so hopefully I'm doing something obviously
wrong. Here's a short runnable code sample showing my basic layout (I'm
using python...
|
by: Robin Dunn |
last post by:
Announcing
----------
The 2.6.3.0 release of wxPython is now available for download at
http://wxpython.org/download.php. There have been many enhancements
and fixes implemented in this version, many of which are listed
below and at http://wxpython.org/recentchanges.php.
What is wxPython?
|
by: Robin Dunn |
last post by:
Announcing
----------
The 2.6.3.0 release of wxPython is now available for download at
http://wxpython.org/download.php. There have been many enhancements
and fixes implemented in this version, many of which are listed
below and at http://wxpython.org/recentchanges.php.
What is wxPython?
|
by: Raja |
last post by:
Hi,
I am trying to develop an application which would mainly do the
following 2 things . I would like to know how it can be achieved and
also the libraries needed for it .
i) active window tracking
In this substate, the application records the title bar
contents of the active/foreground window
and how long, in seconds, that that window is active/in
the foreground. If the same window
| |
by: Grant |
last post by:
Hi, I am looking for a tip. I have a panel and a checkbox. When I
check the checkbox, I would like to add buttons to the panel
(dynamically). When the checkbox is unchecked, the buttons should not
appear (be deleted)---all the while, the window should resize if necessary.
If you have a simpler example, that is fine. I just need a hint as to
how you dynamically change the widgets and their layouts.
Looking at the wx demos, there is...
|
by: citronelu |
last post by:
Hi,
I'm new to wxpython, and the following code is my first serious
attempt:
#~ start code
import wx
class MyPanel(wx.Panel):
|
by: Tyler |
last post by:
Hello All:
I am currently working on a project to create an FEM model for school.
I was thinking about using wxPython to gather the 12 input variables
from the user, then, after pressing the "Run" button, the GUI would
close, and the 12 input variables would then be available for the rest
of the program.
So far, what I have been able to do is mostly a reverse engineering
job to get the frame to look right and return the text variable...
|
by: Andrea Gavana |
last post by:
Hi Diez & All,
Do you mind explaining "why" you find it *buttugly*? I am asking just
out of curiosity, obviously. I am so biased towards wxPython that I
won't make any comment on this thread in particular, but I am curious
to know why some people find it "ugly" or "bad" or whatever. It has
its own bugs and missing features, of course, but it is one of the
major GUI player in the arena, together with PyQt and PyGTK.
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |