You seem to be implying that you'd maintain two versions of your application -- one which runs via Tk, and one which is a console app. This is a lot of extra work. Also, consider that X is running may not be the only appropriate time to use Tk -- Windows, for example, can run Tk apps without an X server available.

There are two problems here -- detecting whether to use a GUI, and creating an application that is dual-mode.

Well, for one thing this won't run under Windows in any case. So that's not a problem. Said this, if you read 432975 more carefully you'll notice that I wrote "[...] in that case I would put most of the non-UI code into a module and call it from the respective '.X' and '.cmd' versions.", which is fundamentally what you suggest yourself.

Taking into account both this circumstance and the fact that after all it will be a relatively simple application, it most certainly won't be "a lot of extra work".

The only problem here is detecting X and running a GUI version if it is available or a CLI version otherwise, which doesn't seem to be a choice everybody agrees on, but that's another matter...

In any case thank you for the feedback!


In reply to Re^2: How to detect X? by blazar
in thread How to detect X? by blazar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.