begin process at 2013 05 23 19:46:19
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

GTK+

 > CALCULATRICE

CALCULATRICE


 Information sur la source

Note :
10 / 10 - par 2 personnes
10,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :GTK+ Classé sous :calculatrice Niveau :Débutant Date de création :21/06/2003 Date de mise à jour :21/06/2003 07:54:31 Vu :10 517

Auteur : Funcky

Ecrire un message privé
Site perso
Commentaire sur cette source (1)
Ajouter un commentaire et/ou une note

 Description

Cliquez pour voir la capture en taille normale
Une calculatrice, simple, avec juste la division, multiplication, soustraction et addition.

Pour comprendre les bases de GTK+

Pour le moment, juste l'affichage, bientôt le calcul et surtout des commentaires ...

Source

  • #include <stdlib.h>
  • #include <gtk/gtk.h>
  • #include <stdio.h>
  • #include <windows.h>
  • struct nombre_struct {
  • float nombre1;
  • float nombre2;
  • float resultat;
  • bool virgule;
  • }nombre;
  • int main(int argc,char **argv)
  • {
  • GtkWidget *principal;
  • GtkWidget *pVBox;
  • GtkWidget *pHBox;
  • GtkWidget *pButton[17];
  • GtkWidget* pLabel;
  • nombre.nombre1 = 0;
  • nombre.nombre2 = 0;
  • nombre.resultat = 0;
  • nombre.virgule = FALSE;
  • gtk_init(&argc,&argv);
  • principal = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  • gtk_window_set_title(GTK_WINDOW(principal),"Calculatrice By Funcky");
  • gtk_window_set_default_size(GTK_WINDOW(principal),200,200);
  • gtk_window_set_position (GTK_WINDOW (principal), GTK_WIN_POS_CENTER);
  • gtk_widget_realize (principal);
  • g_signal_connect (principal, "destroy", gtk_main_quit, NULL);
  • pButton[7] = gtk_button_new_with_mnemonic("_7");
  • pButton[8] = gtk_button_new_with_mnemonic("_8");
  • pButton[9] = gtk_button_new_with_mnemonic("_9");
  • pButton[10] = gtk_button_new_with_mnemonic("_/");
  • pButton[0] = gtk_button_new_with_mnemonic("_0");
  • pButton[1] = gtk_button_new_with_mnemonic("_1");
  • pButton[2] = gtk_button_new_with_mnemonic("_2");
  • pButton[3] = gtk_button_new_with_mnemonic("_3");
  • pButton[4] = gtk_button_new_with_mnemonic("_4");
  • pButton[5] = gtk_button_new_with_mnemonic("_5");
  • pButton[6] = gtk_button_new_with_mnemonic("_6");
  • pButton[11] = gtk_button_new_with_mnemonic("_*");
  • pButton[12] = gtk_button_new_with_mnemonic("_-");
  • pButton[13] = gtk_button_new_with_mnemonic("_+");
  • pButton[14] = gtk_button_new_with_mnemonic("_.");
  • pButton[15] = gtk_button_new_with_mnemonic("_OK");
  • pButton[16] = gtk_button_new_with_mnemonic("_Reset");
  • pLabel=gtk_label_new("0");
  • gtk_label_set_justify(GTK_LABEL(pLabel), GTK_JUSTIFY_RIGHT);
  • pVBox = gtk_vbox_new(FALSE, 0);
  • gtk_container_add(GTK_CONTAINER(principal), pVBox);
  • pHBox = gtk_hbox_new(TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pHBox), pLabel, TRUE, TRUE, 0);
  • pHBox = gtk_hbox_new(TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pHBox), pButton[7], TRUE, TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pHBox), pButton[8], TRUE, TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pHBox), pButton[9], TRUE, TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pHBox), pButton[10], TRUE, TRUE, 0);
  • pHBox = gtk_hbox_new(TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pHBox), pButton[4], TRUE, TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pHBox), pButton[5], TRUE, TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pHBox), pButton[6], TRUE, TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pHBox), pButton[11], TRUE, TRUE, 0);
  • pHBox = gtk_hbox_new(TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pHBox), pButton[1], TRUE, TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pHBox), pButton[2], TRUE, TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pHBox), pButton[3], TRUE, TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pHBox), pButton[12], TRUE, TRUE, 0);
  • pHBox = gtk_hbox_new(TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pHBox), pButton[0], TRUE, TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pHBox), pButton[14], TRUE, TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pHBox), pButton[13], TRUE, TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pHBox), pButton[15], TRUE, TRUE, 0);
  • pHBox = gtk_hbox_new(TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);
  • gtk_box_pack_start(GTK_BOX(pHBox), pButton[16], TRUE, TRUE, 0);
  • gtk_widget_show_all (principal);
  • gtk_main ();
  • return 0;
  • }
#include <stdlib.h> 
#include <gtk/gtk.h> 
#include <stdio.h>
#include <windows.h> 

struct nombre_struct {
	float nombre1;
	float nombre2;
	float resultat;
	bool virgule;
}nombre;


int main(int argc,char **argv)
{ 
	GtkWidget *principal;
    GtkWidget *pVBox;
    GtkWidget *pHBox;
    GtkWidget *pButton[17];
	GtkWidget* pLabel;

	nombre.nombre1 = 0;
	nombre.nombre2 = 0;
	nombre.resultat = 0;
	nombre.virgule = FALSE;

 
	gtk_init(&argc,&argv); 

    principal = gtk_window_new(GTK_WINDOW_TOPLEVEL); 
    gtk_window_set_title(GTK_WINDOW(principal),"Calculatrice By Funcky"); 
    gtk_window_set_default_size(GTK_WINDOW(principal),200,200);
	gtk_window_set_position (GTK_WINDOW (principal), GTK_WIN_POS_CENTER); 
	gtk_widget_realize (principal); 
	g_signal_connect (principal, "destroy", gtk_main_quit, NULL); 

	pButton[7] = gtk_button_new_with_mnemonic("_7");
	pButton[8] = gtk_button_new_with_mnemonic("_8");
	pButton[9] = gtk_button_new_with_mnemonic("_9");
	pButton[10] = gtk_button_new_with_mnemonic("_/");
	pButton[0] = gtk_button_new_with_mnemonic("_0");
	pButton[1] = gtk_button_new_with_mnemonic("_1");
	pButton[2] = gtk_button_new_with_mnemonic("_2");
	pButton[3] = gtk_button_new_with_mnemonic("_3");
	pButton[4] = gtk_button_new_with_mnemonic("_4");
	pButton[5] = gtk_button_new_with_mnemonic("_5");
	pButton[6] = gtk_button_new_with_mnemonic("_6");
	pButton[11] = gtk_button_new_with_mnemonic("_*");
	pButton[12] = gtk_button_new_with_mnemonic("_-");
	pButton[13] = gtk_button_new_with_mnemonic("_+");
	pButton[14] = gtk_button_new_with_mnemonic("_.");
	pButton[15] = gtk_button_new_with_mnemonic("_OK");
	pButton[16] = gtk_button_new_with_mnemonic("_Reset");

	pLabel=gtk_label_new("0"); 
	gtk_label_set_justify(GTK_LABEL(pLabel), GTK_JUSTIFY_RIGHT);
	
	pVBox = gtk_vbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(principal), pVBox);

	pHBox = gtk_hbox_new(TRUE, 0);
	gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);

	gtk_box_pack_start(GTK_BOX(pHBox), pLabel, TRUE, TRUE, 0);

	pHBox = gtk_hbox_new(TRUE, 0);
	gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);

	gtk_box_pack_start(GTK_BOX(pHBox), pButton[7], TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(pHBox), pButton[8], TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(pHBox), pButton[9], TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(pHBox), pButton[10], TRUE, TRUE, 0);

	pHBox = gtk_hbox_new(TRUE, 0);
	gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);

	gtk_box_pack_start(GTK_BOX(pHBox), pButton[4], TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(pHBox), pButton[5], TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(pHBox), pButton[6], TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(pHBox), pButton[11], TRUE, TRUE, 0);

	pHBox = gtk_hbox_new(TRUE, 0);
	gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);

	gtk_box_pack_start(GTK_BOX(pHBox), pButton[1], TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(pHBox), pButton[2], TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(pHBox), pButton[3], TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(pHBox), pButton[12], TRUE, TRUE, 0);

	pHBox = gtk_hbox_new(TRUE, 0);
	gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);

	gtk_box_pack_start(GTK_BOX(pHBox), pButton[0], TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(pHBox), pButton[14], TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(pHBox), pButton[13], TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(pHBox), pButton[15], TRUE, TRUE, 0);

	pHBox = gtk_hbox_new(TRUE, 0);
	gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);

	gtk_box_pack_start(GTK_BOX(pHBox), pButton[16], TRUE, TRUE, 0);
	

	gtk_widget_show_all (principal);
	gtk_main (); 
	return 0; 
} 




 Sources du même auteur

LECTURE DE L'ENTÊTE D'UN FICHIER BMP [GCC]
CONVERTIR UN NOMBRE BINAIRE EN DÉCIMAL ET INVERSEMENT
HEURE SUR AFFICHEUR 7 SEGMENTS [GCC]
Source avec Zip GESTION DE PACK
Source avec une capture PAC-MANIAK

 Sources de la même categorie

Source avec Zip Source avec une capture INFORMATION GTK CONCERNANT UNE TOUCHE par Phelim
Source avec Zip Source avec une capture BINARY CLOCK GTK AVEC CONTRÔLE EN TRAY SOUS LINUX par dje_jay
Source avec Zip Source avec une capture [GTK+] FENÊTRE POPUP ANIMÉE EN BAS À DROITE DE L' ÉCRAN par katsankat
Source avec Zip GTK _CALCUL par jabirmed
Source avec Zip DICTIONNER RECHERCHE GTK par jabirmed

 Sources en rapport avec celle ci

UNE CALCULATRICE TRAITANT LES CARACTÈRES.... par Jbs106
Source avec Zip CALCULATRICE AVEC REPRESENTATION GRAPHIC par msavyo1
Source avec Zip Source avec une capture CALCULATRICE C++ AVEC GUI QT par skylin3
Source avec Zip TUTORIEL N°1 par bioopovega
Source avec Zip CALCULETTE EN C SOUS LINUX AVEC AUTOMATE SIMPLE par pch_hotline

Commentaires et avis

Commentaire de david21 le 16/03/2005 13:35:28

bonjour,
avant toute chose, je voulais te dire bravo, pour ton code qui est pas mal du tout, ensuite, je voudrais te demander si tu sais comment on peut récupérer un float ou un double à partir GtkEntry, merci d'avance et bonne chance pour la suite,

david21

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

Calculatrice ms visual c++ [ par Fino ] Bonjour,quelqu'un aurait-il le source d'une calculatrice faite avec ms visual c++ comme la calc.exe de ms dans windows.si oui pouvez m'en envoyer un e Probleme d affichage [ par Scythale ] Lorsque j'execute ce programme voici ce que dit mon compilateur(borland C++): you have accidentely use the old dummy version of OwlMain.Je n'arrive pa calculatrice en c++ TRES URGENT!!! [ par zouz ] Il faut que je réalise une calculatrice en programmation.Le fonctionnement est comparable à une calculatrice de poche tel que nous avons l'habitude d' Une calculatrice en C++ sous windows [ par Juan-Marco ] Bonjour à tousVoila mon premier post sur ce forums Je connais bien les boucles, les variables et les structures. Je connais un peut moins les classes. calculatrice pour debutant en C [ par kwuy ] j'ai ecrit une version de ma calculatrice mais je voudrais en faire une avec ligne de commande du genre : 12 + 5 - 4 *9 etc et avoir le resultatcommen Calculatrice Win32 Borland OWL C++ 5.x [ par bobby03 ] J'ai ajouté une barre menu, mais je suis incapable d'activer mon MessageBox À propos. Ça ajoute même une erreur sur le code existant qui fonctionne tr Calculatrice Inverse Polonaise [ par vpieplu ] J'ai un probleme. Je n'arrive pas a coder la calculatrice ... Je ne sais qu'elle commande mettre dans les fonctions + - * / Sin Inv Cos C'est super UR calculatrice en C [ par a20syl92 ] 20sylsylnet@netcourrier.comBonjour,J'aimerais réaliser, en langage C, un logiciel capable d'évaluer des expressions arithmétiques, en respectant les p Calculatrice (postfixé) : pb a l'execution [ par filipuce ] Bonjourvoila g fé une petite calculatrice (+,-,*,/ avec parentheses)sous linux pas de probleme, compilation et execution.mais en retouranant sous wind Une calculatrice en C... [ par vegetalain ] bonjour.voila, je débute en C++ et c un vrai cauchemar... j'ai pris sur le net une source de calculatrice. y'a des fichier ".c" et ".h" et aussi des f


Nos sponsors


Sondage...

CalendriCode

Mai 2013
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
2728293031  

Consulter la suite du CalendriCode

Photothèque

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 3,432 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales