ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Im not a programmer and I have a kind of basic knowledge of Linux systems. I would like to know how to build a small application that will allow me to open up a window with say 3 clocks in it - digital or other wise - each showing a diffewrent time. Like for example GMT, GMT +2 and GMT +7.
Maybe there are downloadable programs out there that can do this. But for my own ambitious self, How could I go about doing this. Sort of a learning project? I mean is it possible or do you really have to become a pc boffin?
Any pointers in the right direction would be very much appreciated!
Phil
But for my own ambitious self, How could I go about doing this. Sort of a learning project? I mean is it possible or do you really have to become a pc boffin?
Any pointers in the right direction would be very much appreciated!
Programming is a fairly complex skill. I have never heard of anyone who wrote a reasonably complex program while learning how to program. I suggest that you learn how to program first and then write your time zone program after you have mastered programming basics.
Actually, this sounds like quite a good learning example to me.
Writing a clock is fairly complex; you have to update the display continuously and re-calculate the position of the hands and so on. And writing three at once could be worse than three-times as difficult if you're not careful. But it is also a well-defined problem, and it's not so big as to be totally unrealistic.
But one principle that it's good to learn early on in software is that of code re-use.
* It is usually better to modify an existing program to perform a task than to create a whole new program from scratch.
* Provided you can find suitable libraries, you can build your program using the libraries and get a working result much faster; in doing so, you are also likely to find problems in the library that, when fixed, may will fix problems with other programs the library is used in too.
* More generally, when you write your code in a modular fashion, you will find that there are many fewer side-effects to changing any one bit of code, resulting in fewer bugs, faster program development, and easier testing and profiling. You may also find that parts of your program naturally lend themselves to being used repeatedly. Keep things in small units (typically objects), each with a well-defined purpose and as simple an interface as you can get away with.
I would start by choosing a language: C++ is very good for teaching you about object-orientation, memory management, and accuracy in programming (just make sure you find a good modern book to learn from!). Java is good as a graphical language, with support for threads and powerful error-detection, but can be difficult to learn at first since there is no obvious place to start. Scripting languages like Python can also be useful since they tend to have a simpler syntax and so a less steep learning curve. You should probably research these in more detail.
Next, set yourself some milestones. I would suggest getting a simple, functional-but-ugly digital clock done first, just showing the current time, not even updating. Take it step by step: give it an offset that you can pass into its constructor. The next milestone might be making it update. Then make there be three instances with different times. Then go back and work on the user interface; make it a pretty graphical clock or whatever you want it to look like. Or change the order of these milestones around, but try to build it up in well-defined stages. You can always change these stages as you work through your project.
Now find yourself some teaching materials. I tend to talk about books, but it's the quality of the explanations that matters; blogs and tutorials can be just as good. Read reviews before you read the text. Don't get a book just because it comes with an integrated IDE or a Visual Development Tool that makes things easy; tools just as good as these are freely available online or with your favourite Linux distribution. Go for a book that talks about what you're doing on your first milestone – any good book will tell you how to find out what your programming language can do, and the first stages are slowest since you are learning a lot, so you should use all the help you can get.
Finally, if you get stuck, ask questions: even if your problem seems embarrassingly simple. You will be surprised at what you can learn from getting a second viewpoint on the subject. And that doesn't just apply to programming.
Hope that helps, and do let us know how you get on!
From no programming experience writing graphical applications is a big step. That is why most beginner programming tutorials focus on getting output to a terminal.
I don't want to recommend this as an introduction to programming but the Qt examples have a clock, which is pretty close to what you are after. However if you are determined to achieve the program that you outlined then you may want to look at the Qt tutorials but they do assume a certain level of comfort with C++. This would be a rocky and frustrating journey but there are a number of people here who will help you.
OK I get the point. But Im going to follow up on this.
My thinking is: Its very easy to bring up an xclock, digital or analogue with different colours just using bash commands. So could it not be possible to bring up three of these in one window with one command. Displaying different times of course.
Phil
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.