PyQt5 secondary widget doesn't connect UDF - pyqt5

My two files AAA.py and BBB.py have a QMainWindow and a QWidget respectively. QMainWindow has a button showing QWidget. QWidget has a button and let's say its function is clearing the lineEdit on the widget when it's clicked. These files work fine when directly connect lineEdit to be cleared but I want it to be done when I make a function and call it inside .connect().
I tried to specify the problem and found that UDF is the thing. What I really want to do is save the text in lineEdit into SQL. Clear() is just an example, so please don't say not to use udf.
These files work fine when I implement the clearing like:
self.pushButton.clicked.connect(self.lineEdit.clear)
clear() is just about clearing the lineEdit.
self.pushButton.clicked.connect(self.clear)
Although it also works in BBB.py, but it doesn't when I open the QWidget through AAA.py.
Can you guess what the problem is?

Related

VB.NET - Hiding Form on Load

So theres a few questions on this but they all give the same answer Me.Hide() which "works" if you count that when it loads, It will SHOW but then will hide seconds after which makes a weird Shadow-y-Laggy Effect.
Example:
(The small Window that shows and almost instantly hides is the window im trying to NEVER show)
Is there a way to actually hide the WHOLE form upon load? I know of the whole VisibilityCore method but with that I cant find a way to show it again at a later point.
So is there a way to hide it so it NEVER shows unless I tell it to Show?
Currently im using "Hide() combined with Form.Show Method".
If you set the form's Opacity property to 0 (through the Property Window) you shouldn't have this problem.
When you want to show the form (if it's going to be shown at all) just set the opacity back to 1.0.
Opacity is still a hack. The correct way is to not show it at all, versus making it invisible. To do this, don't make it the "Startup Object" at all.
On the Application tab of the Project Properties screen, there is a Startup Object setting. Create a Module with a Sub Main() and make that the entry point of your app by selecting it as the Startup Object instead of that little form that apparently doesn't do anything visual.
Maybe you have some initialization code in that starting form...move that to Sub Main.
you can minimize the form upon application launch.
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Form fm = new Form1();
fm.WindowState = FormWindowState.Minimized;
Application.Run(fm);
}

Can't View VBA Form

So I created a form, and have been using it for a while.
All of a sudden today it stopped working. Other forms load and can be viewed but not this one.
The weirdest part is that the controls still respond!
So I can't actually see the form but I can still interact with it. (only using keyboard no mouse clicks are responding) I know the form is enabled. But I simply can't see it! I have restarted excel, and the whole computer.
I even completely removed all code in the userform to see if I could get the blank shell to load, and while I can tell it loads (it disables everything in excel until I use Alt+F4) it still won't be visible. I have checked the Enabled, All Colors, Captiuon, Width, Height, Top, Left, StartUpPostion, SpecialEffect, Zoom, DrawBuffer properties and everything is fine.
I have also Exported and reimported it and still simply nothing. Also tried importing it into another Workbook, nothing. I at my wits end (not that it's very far to reach!)
Also, I can still see the userform in the designer I can still edit it, I get NO errors. This happens not only when calling the form in code, but even when running it right from the designer.
Any one ever have this issue? Any ideas or solutions?
The issue ended up being the Top and left properties. While I did check them, they way I checked them was not accurate; I still have no idea why, but I think it defiantly has something to do with dual monitor setup.
The way I tested double checked the forms top and left properties was by creating a new form and adding a button on the button click event I had a msgbox show the top and left properties of the form at time of clicking.
I then moved the new form to where I wanted the form that woudn't show to be and clicked the button; I then set these values to the form that wouldn't show.
I tested this location and made sure to match the properties with the values I wanted multiple times and it didn't work.
For some reason the values needed where about 1000 digits off (instead of 250 I needed to use 1250) even though I had set the form right where I wanted the new one to be and made sure to save the properties when they matched what I wanted

Create a shared copy and paste menu for my grids

I have 20 or so grids in my application suite. I'd like to create a global copy/paste context menu which I can bind to every single grid rather than code in each form.
I am unsure what is the best way to achieve this, I have started to create a class with my menu in it, but get stuck at the point of adding the actual menu options. For example I know I'll need to call a "copy" event, but I also know I'll need to tell it what I am copying, and I cannot see how that is done in vb.net when you can only add the address of a method minus parameters.
e.g.
.MenuItems.Add("Copy Cell", New System.EventHandler(AddressOf CopyCell))
Obviously I want "CopyCell" to only be coded in one place as well, rather than repeated in each form. I will always be copying the same object (SelectedCellCollection).
I am not sure how to make the menu have an event with parameters, or how to make it "know" that I want to always copy the selected items. I'm aware that I'd have to do some coding in the form but just trying to work out the way to minimize it.
I have created my own context menu class (via inheritance) with specific copy and paste functionality / options tailored to the grid I am using. It works fine and only needs one line of code per form/grid to activate.

AutoCAD VBA acadPViewport unpredictable behaviour when setting standardscale

I have a VBA script that imports a layout into an exsting drawing, its a paperspace layout and contains one acadPViewport to view the model with.
I need to set a sensible default view, the easiest way to do this is to set the viewport to the extents of the model.
I can do this by calling:
VP.standardscale = acVPScaleToFit
'(optional, I've tried adding these to no effect)
VP.update
currentDocument.Regen
I've experimented and this code call. If I find the viewport in the immediate window, while not running any macros or routines, by referencing:
ThisDrawing.ActiveLayout.block(1).standardscale = acvpscaletofit
it has the desired effect of calling ZoomExtents within the pViewport (as far as I can tell it recenters and recalculates the extents, which is what I'm looking for).
When I run exactly the same code inside my main code it has no effect.
Any ideas appreciated.
The answer, it turns out, is that many features of AutoCAD won't work if the main application is off-screen, hidden, minimised or was at file load.

play sound triggered by click on form control

I'm trying to trigger a sound by clicking on a form control in Excel 11. The handler for the click event tries to play a sound using sndPlaySound32 if it finds certain text on the clipboard.
I've declared the function sndPlaySound32, and call it with (simplified)
whatSound$ = "C:\WINDOWS\Media\Office97\Drop.wav"
sndPlaySound32 whatSound$, &H0
As long as Excel is the front app when I click the control then everything works fine and the sound plays (if the target text is found on the clipboard), but if I'm bringing the text in on the clipboard from another app like Notepad, where Excel is not the front app when the click occurs, then the first click on the control doesn't produce any sound. Subsequent clicks work normally. Other events on the form have no problem with this and continue to respond normally to the first click.
How can I make the sound play on the first click of the control when Excel is not the front app?
Edit 11/25/10:
I can't make the board Comments work. I click Add Comment but my comments aren't shown, so this is a reply to Boost.
I think it's something deeper than just bringing Excel to the front with the first click, because there are several of other actions that are triggered successfully by this first click on the control, (while another app is in front), and they all work just fine. It's only the playSound that doesn't work until subsequent clicks.
I've tried moving the playSound command both to the front and to the end of the list of other actions (e.g. font changes, text resizing etc.) that are supposed to happen with each click, and also tried putting delays in various places, but no joy. If I step through the code, the playSound procedure gets called correctly on the first click but it doesn't produce a sound.
I don't think there's a fix here. An application will not accept mouse events until it is "in focus." If Notepad is in focus, you will transfer focus from it to Excel with the first click, then Excel's event handlers will come into play and respond to subsequent events.
You could (and I don't know if it's even possible) put a transparent windows over the whole screen and interpret mouse-clicks in that context, and pass them to the appropriate underlying windows. SMOP, I suppose.
I finally found a workaround that's simple, reliable, and ugly. Since it won't play the sound on the first click, I just give it another chance. So now, in place of the code in my original post, it looks like this:
whatSound$ = "C:\WINDOWS\Media\Office97\Drop.wav"
sndPlaySound32 whatSound$, &H0
sndPlaySound32 whatSound$, &H0
It still ignores the first playSound command, but it plays the second one every time on the first click.