473,657 Members | 2,612 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

wxPython DnD stops working after SetSizeHints

This has been driving me crazy for a couple of days and I have finally
narrowed it down to the following code. If the commented section is
uncommented the drag and drop handler is never called. I have included
the .xrc file for reference.

Any help is greatly appreciated. An explanation would be great, but at
the moment I would be eternally grateful for a workaround!

Thanks in advance for those of you that spend some time helping out.

Here is the blasted code,

from wxPython.wx import *
from wxPython.xrc import *

class TestFrame(wxFra me):
def __init__(self,p arent,ID):
wxFrame.__init_ _(self,parent,I D,"test
frame",(100,30) ,(70,60),wxDEFA ULT_FRAME_STYLE )
self.panel=wxPa nel(self,-1)

class FileDropTarget( wxFileDropTarge t):
def __init__(self, window):
wxFileDropTarge t.__init__(self )

def OnDropFiles(sel f, x, y, filenames):
print filenames

class App(wxApp):
def OnInit(self):

self.res=wxXmlR esource("test.x rc")
self.frame=self .res.LoadFrame( None,"FRAME1")
self.frame.pane l=XRCCTRL(self. frame,"test_lis t")

dt=FileDropTarg et(self.frame)
self.frame.pane l.SetDropTarget (dt)

# The following lines break the drag and drop
# self.panel=XRCC TRL(self.frame, "panel")
# sizer=self.pane l.GetSizer()
# sizer.SetSizeHi nts(self.frame)

self.frame.Show ()
self.SetTopWind ow(self.frame)

return True
def main():
app=App(0)
app.MainLoop()
if __name__=="__ma in__":
main()
and here the XRC

<?xml version="1.0" ?>
<resource>
<object class="wxFrame" name="FRAME1">
<title></title>
<object class="wxPanel" name="panel">
<size>100,100 </size>
<object class="wxBoxSiz er">
<orient>wxVERTI CAL</orient>
<object class="sizerite m">
<object class="wxStatic BoxSizer">
<label>test_lis t</label>
<orient>wxVERTI CAL</orient>
<object class="sizerite m">
<object class="wxListBo x" name="test_list ">
<content/>
</object>
</object>
</object>
</object>
</object>
</object>
<size>100,100 </size>
</object>
</resource>
Jul 18 '05 #1
2 2303


"Emiliano Molina" wrote
<snip>
from wxPython.wx import *
from wxPython.xrc import *

class TestFrame(wxFra me):
def __init__(self,p arent,ID):
wxFrame.__init_ _(self,parent,I D,"test frame",(100,30) ,(70,60),wxDEFA ULT_FRAME_STYLE ) self.panel=wxPa nel(self,-1) This gets overwritten -^

class FileDropTarget( wxFileDropTarge t):
def __init__(self, window): unused --------------------^
wxFileDropTarge t.__init__(self )

def OnDropFiles(sel f, x, y, filenames):
print filenames

class App(wxApp):
def OnInit(self):

self.res=wxXmlR esource("test.x rc")
self.frame=self .res.LoadFrame( None,"FRAME1")
self.frame.pane l=XRCCTRL(self. frame,"test_lis t")

dt=FileDropTarg et(self.frame)
self.frame.pane l.SetDropTarget (dt)

# The following lines break the drag and drop
# self.panel=XRCC TRL(self.frame, "panel")
# sizer=self.pane l.GetSizer()
# sizer.SetSizeHi nts(self.frame)
What is self.panel, as opposed to self.frame.pane l?

self.frame.Show ()
self.SetTopWind ow(self.frame)

return True

Hi Emiliano, it isn't clear what you are trying to do here, you seem to
have a panel being created in 3 different places -- which one do you
want? I suspect that the self.panel, is hiding the other panel
that you created (self.frame.pan el) which is the drop target (just a
guess)

I've never used xrc, but this works for me (is it what you want?)

class App(wxApp):
def OnInit(self):

self.res=wxXmlR esource("test.x rc")
self.frame=self .res.LoadFrame( None,"FRAME1")
self.frame.pane l=XRCCTRL(self. frame,"panel")

dt=FileDropTarg et()
self.frame.pane l.SetDropTarget (dt)

# The following lines break the drag and drop
sizer=self.fram e.panel.GetSize r()
sizer.SetSizeHi nts(self.frame)

self.frame.Show ()
self.SetTopWind ow(self.frame)

return True


Jul 18 '05 #2
>> self.panel=wxPa nel(self,-1)

This gets overwritten -^
def __init__(self, window):


unused --------------------^


Yes, you are 100% right, its there because I have been cutting
down the original program bit by bit to find the problem! It
should no longer be there.
# The following lines break the drag and drop
# self.panel=XRCC TRL(self.frame, "panel")
# sizer=self.pane l.GetSizer()
# sizer.SetSizeHi nts(self.frame)

What is self.panel, as opposed to self.frame.pane l?


self.panel is where I am temporarily storing the window that
I am adding the DnD to. One of the steps that I took when
trying to work out where the problem was was to start with
nothing but a frame and a panel and see if I could drop files
into the panel. That worked fine, it was only when I added a
sizer and then had to fit and set hints that DnD broke.

I'm sorryt that the naming is a bit confusing, I posted this
last night as a last desperate attempt before going to bed!
Hi Emiliano, it isn't clear what you are trying to do here, you seem to
have a panel being created in 3 different places -- which one do you
want? I suspect that the self.panel, is hiding the other panel
that you created (self.frame.pan el) which is the drop target (just a
guess)
The confusion is understandable, I should have spent more time
tidying up the code before posting.

self.frame.pane l is used to store the retrieved control to which
the DnD handler is attached. Its called panel because originally
it WAS a panel, its now a wxListBox.

self.panel is used to store the retrieved panel (this one IS a panel,
sorry for the confusion) from which we can then obtain the main sizer
for the frame. If we don't have the sizer we can't call SetSizeHints
to arrange the controls in the window. Its the calling of SetSizeHints
that seems to break the DnD handling. If I don't call SetSizeHints
then DnD works fine and I can drop a file onto the list in the frame
and its name is printed. The frame looks terrible of course, the
controls are only arranged properly when I call SetSizeHints.
I've never used xrc, but this works for me (is it what you want?)

some helpful code

return True


I tried the code you sent on the iBook and no luck, but you mentioned
that it worked so I sent it over to the PC and tried it again. It worked!

I had a close look at it and you have changed the drop target from the
list to the main panel. I did the same with my code on the PC and it
also worked. So the conclusion is that neither your or my code works on
the Mac. Both sets of code work on the PC as long as the drop target is
the panel and not the list.

Thanks for your help and time. Now I have to figure out what is
happening on the Mac.
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5068
by: Curzio Basso | last post by:
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
1
6012
by: Piet | last post by:
Hello, I am still struggling with a dynamic dialog box. I have created a dialog box that will show a variable number of controls depending on a selection made in a ComboBox also present in the frame. The dialog box is not derived from wxDialog, but from a wxFrame. The dialog is initialized as follows: class myDialog(wxFrame): def __init__(self,parent,title):
0
1170
by: Dave Williams | last post by:
Hi, I'm having problems getting IpAddrCtrl working with a frame containing nested sizers generated from an xrc file. Firstly I tried adding it using AttachUnknownControl as per the example code Using XMLResources on the wxPython wiki. This renders but does not size correctly despite my trying many different variations. Because of my nested sizers I also seem to have to SetSizeHints etc at a higher level than in the example. Also I note...
1
2063
by: flupke | last post by:
Hi, i'm trying to convert my java console app to a python gui. Now, the only problem i seem to have at the moment are the resizers for the layout. It seems that for the purpose of what i'm trying to do, specifying the coordinates is easier that fighting with the layout resizers. 1) I have a screen split in 2. Left side is a textcontrol where logging will end up. All text will be appended to the textcontrol. Ideally this should allow...
0
1632
by: flupke | last post by:
Hi, i need to develop a gui which will load several "windows" depending on what the users selects in the menu and i thought i could accomplish this with panels. What i'm trying to do to test this is load an initial panel and then when the user hits a button load a second panel. This doesn't seem to work. 1. what's the appropriate way of switching panels? 2. the loadNewPanel function seem wrong. I always get loading panel two".
10
4084
by: abcd | last post by:
I have a TextCtrl which is set to be multi-line. I have a function say, updateText(msg), which takes some string and appends it to the text control... txtControl.AppendText(msg) .....however, if the text that I am appending would cause the scroll bars to appear/or scroll since the text is long the textcontrol appears to be blank, until you click on the scroll bar...then the text appears. Any ideas? is this is a sizer problem or a...
10
35910
by: markwalker84 | last post by:
Hello everyone! Got a bit of a problem... Two of the panels on my program contain a number of check boxes. The exact number of which is determined by a pair of variables. I have recently implemented a Wizard which changes that number, as well as a save and load function to the program. I know the number of being altered in memory (i added a quick check button) but what i'm struggling with is how to refresh the panel with the new...
6
6207
by: shuf | last post by:
Hello, I am running python 2.4.4 with wxpython 2.6 on Fedora 6. I am trying to set the font color of individual elements in a listbox, but I am not able to with SetItemForegroundColour() (this method does not appear to do anything): #!/usr/bin/env python # -*- coding: UTF-8 -*- # generated by wxGlade 0.4.1 on Thu Mar 22 12:15:29 2007 import wx
9
4424
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...
0
8305
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,...
0
8730
jinu1996
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...
0
8605
tracyyun
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...
0
7321
agi2029
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...
1
6163
isladogs
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...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1950
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.