Wanna learn native GUI programming in UNIX - Linux ?


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Wanna learn native GUI programming in UNIX - Linux ?
# 1  
Old 10-31-2019
GUI Programming. Code works.

Hi ,
wanna learn native GUI programming in Unix-Linux instead of Gtk and Qt.
No problem. You don't need a cross platform Gui toolkit like Gtk and Qt.
And the code and syntax is also not more or less than others.
Check out this code for a simple mainwindow for your application that is openend in the middle of the screen.
Save code as mainwin.c file.
Go in the folder with terminal and compile with the command :
Code:
clang -o newone  mainwin.c  -lXm -lXt -lX11

When it is ready then write in the same folder terminal :
Code:
chmod 777 newone

Start the executable file from normal file browser with a double klick.
You see a main window GUI in the middle of your screen.
Thats it.
All works propertly. Since 30 Years. Only cross compile applications need a different toolkit.
Change the size of the window simple by other dimension data.
Of course you should have installed 'clang' compiler and 'motif' toolkit with your
synaptic package manager programm that is on your UNIX machine.

Code:
 #include <Xm/Form.h>
#include <Xm/Label.h>
#include <Xm/PushB.h>


int main ( int argc, char ** argv )
{
    Widget              shell, form, label, button;
    XtAppContext app;
    int  i;


    shell = XtAppInitialize ( &app, "Formtest", NULL, 0,
                          &argc, argv, NULL, NULL, 0 );

    Screen * s = XtScreen(shell);

    int dw = WidthOfScreen(s);
    int dh = HeightOfScreen( s );

    Dimension px = (dw-500)/2;
    Dimension py = (dh-300)/2;

    XtVaSetValues ( shell,
              XmNwidth, 500,
              XmNheight, 300,
              XmNx, px,
              XmNy, py,
              NULL );


    form = XtCreateManagedWidget ( "form", xmFormWidgetClass,
                                shell, NULL, 0 );

    label = XtVaCreateManagedWidget ( "label", xmLabelWidgetClass,
                                form, NULL, 0 );

    button = XtVaCreateManagedWidget ( "button", xmPushButtonWidgetClass,
                                form,
                                XmNbottomAttachment,       XmATTACH_FORM,
                                 0 );
    XtVaSetValues ( button,
              XmNwidth, 100,
              XmNheight, 50,
              NULL );


    XtRealizeWidget ( shell );
    XtAppMainLoop ( app );

}


Last edited by Sennenmut; 10-31-2019 at 03:44 PM.. Reason: more description
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Fedora

Which is the better platform to learn UNIX/Linux (Kali Linux Vs. Red Hat or other)?

I just started a new semester and I started my UNIX class yesterday. I've already decided to use python along with my learning process but what I really want to use with it is Kali as my UNIX/Linux platform to learn off of since I already wanted to learn Cyber Sec. anyways. I just wanted to know if... (12 Replies)
Discussion started by: ApacheOmega
12 Replies

2. Fedora

Which flavor of UNIX or Linux to learn?

Hi all, Noob here. I have been dabbling with Linux for years, basically installing different types of distros and becoming familiar with the default gui that came along with it. At this point, I find myself wanting to learn alot more. It would be great if that knowledge helped me move forward... (2 Replies)
Discussion started by: Petros_K
2 Replies

3. UNIX for Dummies Questions & Answers

Open-source projects to learn concurrency-managed network programming in Unix?

Hi, I am a mid-career programmer with extensive experience in object-oriented design and development in C, C++, and C#. I've written a number of multi-threaded server applications and background services, although my grasp of networking protocols is a bit weak: my current job drifted away from... (2 Replies)
Discussion started by: TheTaoOfPhil
2 Replies

4. UNIX for Dummies Questions & Answers

I have to learn UNIX/LINUX/VIM/EMACS

I need some advice from people who use command line frequently and know how to use both VIM and EMACS pretty well for their daily tasks. Please no opinion on which one better etc..., I got enough at that from the Internet. A little about my professional background: I have been a firmware... (2 Replies)
Discussion started by: gspec
2 Replies

5. Shell Programming and Scripting

Best way to learn UNIX and shell Programming

Guys, What do you think is the best way to learn UNIX and shell scripting? ** I keep on searching tutorials online, where I loose most of my time :( Let me know the way you learnt the UNIX concepts, your replies might help me learn more. Thanks a ton:b: (2 Replies)
Discussion started by: dnam9917
2 Replies

6. Fedora

Is it better to learn Linux before unix?

I want to learn (unix solaris), but someone advised me to learn (Linux fedora) before trying (unix solaris) and that they are almost the same.. So shall I go with his advise or is it better to start learning unix directly? (1 Reply)
Discussion started by: proud
1 Replies

7. Programming

How to modify this c code to get full GUI interface for Unix Linux ?

Hi, the following code comes from Unix Linux dialog utility project. Unfortunately, this project is no more actively maintained. Unix Linux dialog utility is made of widget boxes. One of them is mixedgauge.c In the following example I would like to get rid of flickering when run in... (0 Replies)
Discussion started by: jack2
0 Replies

8. UNIX Desktop Questions & Answers

Running MS-windows GUI from unix/linux

Hi i need some help , i would like to run a GUI application on windows from unix i dont need to see the gui just to activate it from remote . it shoud be from CLI on the unix . thanks GUY (1 Reply)
Discussion started by: koreng
1 Replies

9. UNIX for Dummies Questions & Answers

total windows cripple wanna learn unix well

hello, I finally installed a unix port (NetBSD) on my workpad z50 and now I'm trying to configure it and well right about now I know 2 commands and I can start one program Vi is the program and I can navagate with cd and ls those are the two commands wait I know 3 date I also know but I can't even... (3 Replies)
Discussion started by: terramir
3 Replies

10. Programming

Want To Learn Network Programming

I want to learn Network Programming with C,but I don't know how to start. Thank you. (2 Replies)
Discussion started by: hubin330
2 Replies
Login or Register to Ask a Question