SpiritualMadMan 39 Junior Poster in Training

What method are you using to "Open" the file in Question?

I have a Form I copy into my project space when I want to access files...

Copy the code below into a text file and then rename it FN.frm

Because the FN form can be thought of as a separate Class or Object anything on the form can be accessed using FN. until the form is unloaded.

Let me know if it helps. :)

VERSION 5.00
Begin VB.Form FN 
   AutoRedraw      =   -1  'True
   Caption         =   "Select Files"
   ClientHeight    =   7950
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4365
   Icon            =   "FN.frx":0000
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   7950
   ScaleWidth      =   4365
   StartUpPosition =   2  'CenterScreen
   Begin VB.TextBox txtNewFile 
      Height          =   435
      Left            =   105
      TabIndex        =   8
      Text            =   "Text1"
      Top             =   3570
      Width           =   4110
   End
   Begin VB.ComboBox cmboExts 
      Height          =   315
      Left            =   2205
      TabIndex        =   5
      Text            =   "Combo1"
      Top             =   3000
      Width           =   1995
   End
   Begin VB.FileListBox File1 
      Height          =   2820
      Left            =   2200
      TabIndex        =   2
      Top             =   90
      Width           =   2000
   End
   Begin VB.DirListBox Dir1 
      Height          =   2790
      Left            =   120
      TabIndex        =   1
      Top             =   100
      Width           =   2000
   End
   Begin VB.DriveListBox Drive1 
      Height          =   315
      Left            =   100
      TabIndex        =   0
      Top             =   2940
      Width           =   2000
   End
   Begin VB.Label Mode 
      AutoSize        =   -1  'True
      Caption         =   "0"
      Height          =   195
      Left            =   1050
      TabIndex        =   9
      Top …
SpiritualMadMan 39 Junior Poster in Training

OK, I have a Class for a Frame that is basically 24 labels in a stack like an old terminal Screen.

There are two Functions included in the Class: AddLine and Clear (Will add "Exit")

I want to launch an instance of this Class in it's own Thread and Pass Information to it.

I suspect I can do this with PubSub using three Messages: "Clear", "AddLine" and "Exit"

Publisher().sendMessage("Clear", True)
Publisher().sendMessage("AddLine", message_information)
Publisher().sendMessage("Exit", True)


My problem is that the Long Running Process example has things backwards from what I need. The Example has the Worker Thread being the "Sender"

My Worker Thread needs to be the "Subscriber" and my "Main" Script needs to be the "Sender".

Once the Thread is Started and the Frame displayed in the Thread, I want to be able to "Send" 'AddLine' messages to the thread throughout the life of the Main Application and when I am ready to Close the Application "Send" an "Exit" message and shut everything down Gracefully.

This, to me, infers I would be "Listening" for three distinct messages, requiring three separate Publisher event monitors?

Publisher().subscribe(self.Clear, "Clear")
Publisher().subscribe(self.AddLine, "AddLine")
Publisher().subscribe(self.Exit, "Exit")


I suspect that I could also do thid using three events...

SpiritualMadMan 39 Junior Poster in Training

Was able to get to the Blog after all.

I recieved the following recommendations from the author:

http://wiki.wxpython.org/LongRunningTasks

http://www.blog.pythonlibrary.org/2010/05/22/wxpython-and-threads/

http://www.blog.pythonlibrary.org/2010/06/27/wxpython-and-pubsub-a-simple-tutorial/

Can't get to the Wiki from work, I tried, so, it's homework. :)

Gribouillis commented: good luck +13
SpiritualMadMan 39 Junior Poster in Training

Blocked at work will check when I arrive home... THANKS!

SpiritualMadMan 39 Junior Poster in Training

This is something that is really starting to bug me about Python and wxPython...

In VB6 (Disallowed by my employer) I can have multiple Forms loaded at the same time. I can show and hide each and everyone of these forms any time I want to.

For example I can have a Main.bas and Main Form MN, A General Information Form GI and I can talk between each of these "pieces" of my puzzle. In my Main Module I can >show or .Hide MN without affectuing the GI form.

An event in either Form (when shown and both can be shown at the same time with full event handling even when the Main Module has control!) Can reference any Function anywhere in Main and I can access any Control on either form from either form or from Main, simply by, example, MN.List1.Additem("New Information")

What I need to do is have two forms up at the same time... And, I need to be able to pass information to and from each form. I also need to reference functions back in the Main Code and have those Functions act on the Forms. Lastly, I need to be able to kill either form with out affecting the other.

Now, does anyone know where a spoiled by VB6 NEWBIE can find a detailed explanation of how to do what I *must* do to make my program work "correctly"?

I have found *very* incomplete explanations about Threads and Events, …

SpiritualMadMan 39 Junior Poster in Training

Honestly, I am not quite sure how to explain this...

I have a 24 Line GUI wxPython Class that has no Events and Two Functions...

These Functions are: Clear the Display and Add a Line from the Bottom.

I want to use this Frame from beginning to end of the program to Log Events and Test Results for the User... I am *not* interested in Logging to the Console. In fact I do *not* want the Console to be visible at all. (But, that's another issue.)

When I use the following code without bringing another Form Up, the Form Initializes but does not completely fill-in.

When I bring up another Form, the LogScrn GUI fills in and accepts the next .AddLine()

But, when I "Continue" from that second GUI everything halts until I close the LogScrn GUI.

I may need to spawn a second thread for the LogScrn gui? But, I do *not* know how to do that, and even if I did I wouldn't know how to "talk" to the LogScrn from the rest of my code...

As a Python/wxPython newbie I am not even sure how to frame the search to find an answer...

Help (anyone have a drowning programmer animated Smilie?)

logapp =wx.PySimpleApp(0)
wx.InitAllImageHandlers()
LogScrn = Lines_24(None, -1, "")
LogScrn.AddLine("This is the Log Screen Started at: ")
LogScrn.Show()

note that there is no .MainLoop because I realize that that would halt all program execution until the LogScrn …

SpiritualMadMan 39 Junior Poster in Training

OK...

It doesn't work the way *I* was doing it... :)

Original Calling Module Code

ptf={"UUT_Info":UUT_Info(), "Load_Menu":Load_Menu()}
Test_Control(ptf)

Original Called Module Code

def Test_Control(ptf):
    # print "Module_Count: " + str(TC_Config.Module_Count)
    # print "I made it to Test Control"
    ptf.get("UUT_Info")
    if TC_Config.TPS_Status == "Continue":
        # print "I am Continuing..."
        ptf.get("Load_Menu")
        Main_Menu()
        
    if TC_Config.TPS_Status == "Exit":
        print "User Exit From UUT_Info Display"

According to my extremely busy elsewhere Python Guru the closing parens after the Function name in the Dictionary was telling Python to invoke the Function...

I had tried removing those parens, but, then lost the display...

The New Calling Code

ptf={"UUT_Info":UUT_Info, "Load_Menu":Load_Menu}
Test_Control(ptf)

Note the removal of the parens after UUT_Info and Load_Menu .

The New Called Code

def Test_Control(ptf):
    # print "Module_Count: " + str(TC_Config.Module_Count)
    # print "I made it to Test Control"
    ptf.get("UUT_Info")()
    if TC_Config.TPS_Status == "Continue":
        # print "I am Continuing..."
        ptf.get("Load_Menu")()
        Main_Menu()
        
    if TC_Config.TPS_Status == "Exit":
        print "User Exit From UUT_Info Display"

Note the addition of the parens after the ptf.get(xxxx)()

You can either pass a long list a arguments, or you can create a dictionary.

The choice is yours...

SpiritualMadMan 39 Junior Poster in Training

DOES NOT WORK!!!!!!

Discovered a major flaw with using a Dictionary to pass the references to Functions to the Other Module...

As the References are added to the Dictionary they are acted upon/run...

Clearly this isn't what I had in mind. :)

So, I will pass a rather long list of arguments instead...

SpiritualMadMan 39 Junior Poster in Training

Actually, the self.destroy is one of the issues I was interested in, but, not they way it was answered...

When I create "Display" using the UUTInfo Class...

It would be preferrable to "kill" the GUI using Display.destroy (or whatever the correct equivalent is...)

However, once I am "up" in the GUI my ptf code doesn't "see" the events self.onContinue and self.onExit so it can't "destroy" the "Display" instance until after the self "dies".

What I want to do is move the event handling out to the "Display" instance of the "UUTInfo" class...

SpiritualMadMan 39 Junior Poster in Training

Never did much stuff with "Classes" while still writing in VB6. :)

I have the following wxPython Class in my pyTC file

class InfoUUT(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: InfoUUT.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.label_1 = wx.StaticText(self, -1, "This TPS is for the following UUT")
        self.label_9 = wx.StaticText(self, -1, "Please Enter UUT Revision and Serial Number")
        self.label_2 = wx.StaticText(self, -1, " Manufacturer:")
        self.Man_Name = wx.StaticText(self, -1, "")
        self.label_3 = wx.StaticText(self, -1, " Model Number:")
        self.ModNumber = wx.StaticText(self, -1, "")
        self.label_4 = wx.StaticText(self, -1, " Revision:")
        self.Revision = wx.TextCtrl(self, -1, "")
        self.label_5 = wx.StaticText(self, -1, " Military Desgination:")
        self.MilDesig = wx.StaticText(self, -1, "")
        self.label_6 = wx.StaticText(self, -1, " Nomenclature:")
        self.Nomen = wx.StaticText(self, -1, "")
        self.label_7 = wx.StaticText(self, -1, " Part Number:")
        self.PartNo = wx.StaticText(self, -1, "")
        self.label_8 = wx.StaticText(self, -1, " Serial Number:")
        self.SerNo = wx.TextCtrl(self, -1, "")
        self.panel_1 = wx.Panel(self, -1)
        self.btnContinue = wx.Button(self, -1, "Continue")
        self.btnExit = wx.Button(self, -1, "Exit")

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.onContinue, self.btnContinue)
        self.Bind(wx.EVT_BUTTON, self.onExit, self.btnExit)
        # end wxGlade

    def onContinue(self, event):
        print "onContinue Occured"
        TC_Config.UUT_SN = self.Revision.GetValue()
        TC_Config.UUT_Rev = self.SerNo.GetValue()
        TC_Config.TPS_Status = "Continue"
        self.Destroy()
        

    def onExit(self, event):
        print "onExit Occured"
        TC_Config.TPS_Status = "Exit"
        self.Destroy()


    def __set_properties(self):
        # begin wxGlade: InfoUUT.__set_properties
        self.SetTitle("UUT Information")
        self.SetSize((489, 393))
        self.SetBackgroundColour(wx.Colour(192, 192, 192))
        # self.label_1.SetBackgroundColour(wx.Colour(192, 192, 192))
        self.label_1.SetFont(wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, ""))
        # self.label_9.SetBackgroundColour(wx.Colour(192, 192, 192))
        self.label_9.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, ""))
        self.label_2.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, ""))
        self.Man_Name.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.label_3.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, ""))
        self.ModNumber.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, …
SpiritualMadMan 39 Junior Poster in Training

The Dictionary Method seems to be working with multiple entries so I am going to consider this one solved.

Some comments were indecipherable. :)

The whole point of moving to Python from VB6 is to be Cross-Platform and have a common set of Classes against which to build Test Programs.

SpiritualMadMan 39 Junior Poster in Training

I may have solved my problem:

I created a Dictionary ptf = {"UUT_Info":UUT_Info()}

And, I call Test_Control(ptf)

in the pyTC file I changed the

def Test_Control(fn):
    fn()

-to-

def Test_Control(ptf)
    ptf.get("UUT_Info")

I'll consider this "Solved" after I add a few more items to the Dictionary.

But, what I have here seems to work. (Whew!)


to -> pyTony sorry sometimes what is clear to me can't easily be put into words with brevity.

Basically program flow is as follows:

1. user starts/runs the ptf.py file

2. ptf.py file initializes a few Common variables and passes control to Test_Control() in the pyTC.py file.

3. The next step is to display the UUT Information to the user. The Class for the UUT Information Display is in the pyTC.py file.

But, it is "Frozen" and the programmer is not allowed to modify it.

So, UUT_Info in the ptf.py file Instantiates an instance of the UUT Information Display Class.

Loads up the Unique Information and then Shows the Frame.

Where it was failing was after control was passed to Test_Control() in the pyTC.py file, Python could no longer find UUT_Info() in the ptf.py file because of namespace issues.

Is this clear as mud? :)

SpiritualMadMan 39 Junior Poster in Training

Here's My Problem:

I have three Python Modules (using 2.7.2)

TC_Config.py merely holds Common Variables used by both of the other two Modules.

pyTC.py is supposed to be a Test and Flow Control (Master) Module that once standardized will not be changed (much).

ptf.py is a module that will be unique to whatever test is being done.

pyTC.py:

import TC_Config
from wx import *
from time import *
from visa import *
from os import *

def MakeConstant(value):
    def GetIt():
        return value
    retutn GetIt

STTO = MakeConstant(False)

def Test_Control():
    UUT_Info()

ptf.py: (This is the Calling or Origination Module)

import TC_Config
from pyTC import *

TC_Config.Module_Count = 1

def UUT_Info():
    if __name__ == "__main__":
        app = wx.PySimpleApp(0)
        wx.InitAllImageHandlers()
        Display = InfoUUT(None, -1, "")
        Display.Man_Name.SetLabel(" Intellipower, Inc.")
        Display.ModNumber.SetLabel(" IHT2KGACDC-2184")
        Display.MilDesig.SetLabel(" ")
        Display.Nomen.SetLabel(" SWAN-D UPS")
        Display.PartNo.SetLabel(" ")
        Display.SerNo.SetLabel(" 2KCAGDCI09390606")
        app.SetTopWindow(Display)
        Display.Show()
        app.MainLoop()


Test_Control()

if I call UUT_Info from here (instead of calling Test_Control) it works fine...

When I call from pyTC it errors out as undefined global name...

if I pass it as a function:

Test_Control(UUT_Info)

Modifying -->
Test_Control(fn)
fn()

It works...

But, the idea is that the Standardized Classes for the Test Control and Display will be in pyTC and the Unique Data will be in the ptf.py file...

*AND* UUT_Info is only one of many functions I'll need to call back into ptf.py for.

SpiritualMadMan 39 Junior Poster in Training

That is correct.

I have not been able to install *any* Service Packs.


Apparently the closing registry entries are locked down even for a developers account and therefore when the service Packs try to locate those critical registry entries they aren't there and they don't even try to install.

I've moved to a laptop. But, I have to use an approved device to transfer the compiled version back to the NMCI machine to test, because the 3rd party program I am interfacing to requires a net connect for licensing....

Pray For Me!

SpiritualMadMan 39 Junior Poster in Training

Thanks. In my case I created the basic program and then copied the Resource file into the old folder...

I agree that VS6 can be a bit buggy. But, in support of our Marines sometimes you have to support legacy stuff.

I've got 2010 Express loaded up. But, no actual use for it, yet.

(And, they aren't going to buy six copies of 2010 unless they absolutely have to...)

No matter how much hair I pull out over the buggy-ness! :)

Also, we are running WinXP. Unfortunately, it's a government computer and one thing I absolutely can't do is turn off the AV or any other "Security" measure no matter how crippling it is to our productivity.

Which is why I have never gotten a true and complete install of VS6 nor can I install any service packs as they can't find any VS6 products!

Gotta love those paranoid IT security types. :(

SpiritualMadMan 39 Junior Poster in Training

I am getting the following error when I try to access my Resource Files in Visual C++ v6

"The file is already open in an editor."

I've tried closing all windows in the IDE and closing the project, even tried logging out and back in.

All to no avail.

A google search turned up only a few ideas, in English, and they didn't work.

I *really* don't want to have to reenter the entire project.

Thanks!

SpiritualMadMan 39 Junior Poster in Training

I have a 3rd party DLL interface to a program that I need to interface to.

I have C++ Example code that does what it says it does.

But, even though it is very bare bones, I really don't understand it at all.

The example is written for and I am usind C++ (VS6).

STDMETHOD(Input)(LONG lType, BSTR sFmt, BSTR * pVal)
{
    if (pVal == NULL)
        return E_POINTER;
    *pVal = ::SysAllocString(L"TRUE"); // Added
    return S_OK; // Changed
}
STDMETHOD(Output)(BSTR val)
{
    USES_CONVERSION; // This line and line below are added
    ::MessageBox(NULL, OLE2T(val), _T("ButtonResource"), MB_OK | MB_ICONINFORMATION);
    return S_OK; // Changed
}

These are the code snippets I want to modify.

Note: INPUT and OUTPUT is referenced to the 3rd party DLL. The sample code is set up as a simple ATL Object and the project compiles to an EXE that self-registers using the /RegServer command line option.

What I would like to do is add a form that would pop-up the first time the 3rd party DLL "hits" my code and would stay up until I manually kill it.

I would also like two ListBoxes one to show the OUTPUT string from the DLL and another to show the INPUT request parameters.

Everytime I try to add anything to the project I break it!

I am a pretty good VB6 programmer. But, this C++ stuff has me totally mystified.

*ANY* (positive) help would be appreciated.

:)

Mike Sr.

SpiritualMadMan 39 Junior Poster in Training

This thread has not been marked solved so let me offer a suggestion...

I have been writing VB6 code to use the NI VISA32.dll for a while and it is not that hard to talk SCPI to the newer instruments.

The older HP Instruments, like the 8902, 8903 and 3458A require a little more finese.

If you are willing to convert some VB6 code. I am willing to try to help.

Note: You *really* need to look at a VISA interface. Doing direct control of GPIB, USB, Serial, VXI, PXI, MXI or AXIe without that interface is going to be ridiculously difficult.

I haven't used them, yet. But, the IVI drivers look interesting.

But, for just poking the SCPI out to an Instrument, VISA is the way to go.

And, if you have any NI product I believe the NI VISA32 license is free in that case.

Mike Sr.

SpiritualMadMan 39 Junior Poster in Training

Please direct me if this has been answered previously.

Here's my problem. I am decidedly not a C++ Programmer.

I do pretty good with VB6...

I have a 3rd Party program that I need to write a replacement User GUI for.

The company has provided a .DLL and the interface example is for C++ ATL COM

(I have tried to add a form and control to their example only to have the thing fall apart when I do.)

Is there a way to implement an ATL COM interface in VB6.

Thanks,

SpiritualMadMan 39 Junior Poster in Training

OK, By way of introduction I am a 58 year old 6 year Viet Nam Era (not in country) Navy Type who learned a lot of Electronics back in the 70's when the Navy Schools gave you the equivalent of an Associates Degree in Electronics.

I am married with two fantastic grown kids.

I worked everything from IMA Maintenance on the early TACAMO. To Embedded Hardware Design. To Metrology. (Not Meteorology!)

I've maintained my love for the Electronic Arts. But, have found that far too much of my creativity has been ISO'd out and I basically became a trained monkey.

I had been using VB6 to solve problems and do Test Instrument Control for several years and am pretty good in that respect. But, just because you can access the NI_VISA API doesn't mean you are an API guy. :)

I applied for and got "promoted" into a Software Support Team for USMC ATE. I have been to TYX's C/Atlas school. But, it is _NOT_ a language you learn in a week.

After my promotion I have found that as a Windows & VB6 programmer I am the Red-Headed Step-Child of the group of Linux Proponents who are C++ aware. And, of course, Visual Basic is *NOT* a programming language.

Even though there is some VB6 stuff for me to support almost everything is C++ (VS6) based.

And, that's why I joined DaniWEb. My VB6 knowledge is getting in the way of …