Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Wanna learn native GUI programming in UNIX - Linux ? Post 303040558 by Sennenmut on Thursday 31st of October 2019 01:46:10 PM
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
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

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

8. 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

9. 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

10. 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
XtVaAppInitialize()													       XtVaAppInitialize()

Name
  XtVaAppInitialize - initialize the X Toolkit internals, using varargs argument style.

Synopsis
  Widget  XtVaAppInitialize(app_context_return,  application_class,  options, num_options, argc_in_out, argv_in_out, fallback_resources, ...,
  NULL)
	 XtAppContext *app_context_return;
	 String application_class;
	 XrmOptionDescList options;
	 Cardinal num_options;
	 int *argc_in_out;     /* was type Cardinal * in Release 4 */
	 String *argv_in_out;
	 String *fallback_resources;

Inputs
  application_class
		 Specifies the class name of the application.

  options	 Specifies the command line options table.

  num_options	 Specifies the number of entries in options.

  argc_in_out	 Specifies a pointer to the number of command line arguments.  This argument was a Cardinal * in Release 4, and is an  int  *
		 in Release 5.

  argv_in_out	 Specifies the command line arguments array.

  fallback_resources
		 Specifies resource values to be used if the application class resource file cannot be opened, or NULL.

  ..., NULL	 A  NULL-terminated  variable-length  list of resource name/value pairs to override any other resource specifications for the
		 created shell.

Outputs
  app_context_return
		 Returns the application context, if non-NULL.

Returns
  A toplevel shell widget of class applicationShellWidgetClass.

Availability
  Release 4 and later.

Description
  XtVaAppInitialize() initializes the Toolkit internals, creates an application context, opens and initializes a  display,  and  creates  the
  initial  application	shell.	It is identical to XtAppInitialize() except that the args array of resource names and values and the num_args
  argument of that function are replaced with a NULL-terminated variable-length argument list.

  See XtAppInitialize() for more information on this function.	See XtVaSetValues() for more information on  using  variable-length  argument
  lists to specify resources.

See Also
  XtAppInitialize(1), XtVaSetValues(1).

Xt - Initialization													       XtVaAppInitialize()
All times are GMT -4. The time now is 11:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy