Solved

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

Posted on 2004-04-18
10
305 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
10 Comments
 
LVL 5

Accepted Solution

by:
crazycomputers earned 125 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
 
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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 125 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now