To use Perl/Tk or not to use Perl/Tk, that is the question...

We have a DOS based application that updates price changes on PLUs and copies these updates to each of our stores.  We use 4 batch files as wrappers (separating the stores by division) then cycle through each of the store numbers and executes the application for each one, passing the store number to the app.

My plan, which I’m not sure if it’s a good one, is to use Perl/tk as a wrapper instead of the batch files and create a window with a grid of 4 widgets.  Each of these widgets would run and display the price change program for each division.  The dos app uses a static number of lines for its display but ‘updates several fields’ within the display.

I’ve never done any GUI programming, but I have started reading Mastering Perl/Tk (O’Reilly) so the questions are:
1)      Is Perl/tk the proper/best approach?
2)      If not, what is the proper/best approach?
3)      So far, I haven’t seen any code examples that will display the dos app in a widget.  Does anyone know if it can be done and how to code it?
LVL 28
Who is Participating?

Improve company productivity with a Business Account.Sign Up

crazycomputersConnect With a Mentor Commented:
1) Could be.  It would work for this approach, but maybe not the best.
2) C.  =)
3) Create four textboxes and then open each batch file as a process (maybe using command if that doesn't work):

open(BAT1, " /c batchfile.bat") or die "can't run batchfile.bat";
# same with other four

Then read() from BAT1 and append chars to the textboxes as they come in.  If I were running Linux right now I'd code something up (using Linux programs like 'cat' as an example), but, alas, Windows still has its uses.
FishMongerAuthor Commented:
Cazycomputers, thanks for your input.

Re: 2)  I should have clarified that I'm looking for the best Perl GUI solution.  I realize that C would be a much better choice, but unfortunately, I don't know C.  However, I recently picked up Visual C++ and plan on learning it as soon as I can find some free time.

Re: 3)  Unfortunately, that won't do what I need.  First, I don't want to use the batch file, the plan is to use the Perl script as the wrapper.  To me, it doesn't make sense to use the Perl script as a wrapper to the batch file which is in turn a wrapper for the dos application.  Second, the price change application doesn't produce lines of output like cat or ls would, instead it has a predefined text based format with several fields of data that gets updated.

My thought was to divide the main window into 4 dos/cmd windows (or the equivalent) and run the dos application simultaneously in each window, passing the appropriate store numbers to each.  So the question is, can this be done with Tk or other Perl GUI?  And if so, how to code it?
You'd need to write a module with XS probably (XS is like Perl-ish C).  Because Perl is cross-platform, the widget for "DOS boxes" probably doesn't exist, as it would crash on other OSes.
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

FishMongerAuthor Commented:
>> the widget for "DOS boxes" probably doesn't exist

After scanning through the Mastering Perl/Tk book, page 266 shows a code snippet that adds a menu item that does a sorted dir listing on a Windows machine and its output "Figure 12-4 shows a DOS window..." on pg 267 which looks to be within a Tk widget.  So, I guess I'll need to do some addtional reading to put the bits and peices together to produce the complete code that they used, in-order to see if it can be adopted to do what i need.
And, if that book came with a CD-ROM, try looking at the source on there.
FishMongerAuthor Commented:
Well, the book didn't come with a CD and so far I haven't found where/if I can download the code for the examples.
icrfConnect With a Mentor Commented:
With IO::Tty and IO::Pty, I'd assume a relativly platform independent version could be made, but I don't see one, so maybe I'm wrong. Last I checked, Perl/Tk was not thread safe, so that may be a hold up (updating consoles and independent processes).

I don't think I understand what you're trying to do and why opening the command as a pipe and reading it wouldn't work. Can you describe the final use case in detail? How is starting the process and reading from it different from embedding a terminal and having it run there? Is it a concern with having many of them going at one time?
FishMongerAuthor Commented:
My apologies, once again I've been procrastinating.  Unfortunately, even though there were a couple of good responses, none of them dealt with the core question.  I'm at fault because I didn't respond to icrf's post clarifying in more detail what I need.  The core problem is working out the proper Tk code that will take 4 separate running programs each within their own Tk window/widget and nest them into the main window.  It's not clear, but it seams that neither of you (crazycomputers or icrf) have any experience using Tk.  The decision to use a system call vs pipe vs whatever is secondary.

Based on the reading that I've done and the issue of how the program outputs its data, it seams that the system call might be my best choice, but I could be wrong.  I have scanned a portion of my book that indicates that a bidirectional pipe might work, but I'll need to do some further study.  So, I've decided to split the points in appreciation of your help and understanding.

As for now, management has decided to put this project on hold.  As soon as I'm able to, I'll work up some code and see if you can help work out the kinks.

Thanks  :-)
Actually, I do have experience with Tk, just not with DOS-box widgets -- I've never seen (or heard of) them until you mentioned seeing them in a screenshot.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.