Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-04-18
10
Medium Priority
?
320 Views
Last Modified: 2012-08-13
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?
0
Comment
Question by:FishMonger
  • 4
  • 4
9 Comments
 
LVL 5

Accepted Solution

by:
crazycomputers earned 375 total points
ID: 10864425
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, "command.com /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.
0
 
LVL 28

Author Comment

by:FishMonger
ID: 10865814
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?
0
 
LVL 5

Expert Comment

by:crazycomputers
ID: 10870721
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.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 28

Author Comment

by:FishMonger
ID: 10871738
>> 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.
0
 
LVL 5

Expert Comment

by:crazycomputers
ID: 10871871
And, if that book came with a CD-ROM, try looking at the source on there.
0
 
LVL 28

Author Comment

by:FishMonger
ID: 10884072
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.
0
 
LVL 2

Assisted Solution

by:icrf
icrf earned 375 total points
ID: 10905647
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?
0
 
LVL 28

Author Comment

by:FishMonger
ID: 11086829
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  :-)
0
 
LVL 5

Expert Comment

by:crazycomputers
ID: 11087080
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.
0

Featured Post

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question