Home Database Mysql Tutorial GTK2.0+学习

GTK2.0+学习

Jun 07, 2016 pm 03:00 PM
Prepare study observe first

GTK2.0 学习 1. 准备 首先观察 gtk2.0 开发包为我们提供的一个文档。阅读下文,您可以知道,对于刚开始开发,我们应该做些什么。 Then add the bin folder to your PATH. Make sure you have no other versions of GTK in PATH. Run: pkg-config --cflags gt

GTK2.0+学习

1.准备

首先观察gtk2.0开发包为我们提供的一个文档。阅读下文,您可以知道,对于刚开始开发,我们应该做些什么。

Then add the bin folder to your PATH. Make sure you have no other

versions of GTK+ in PATH. Run:

    pkg-config --cflags gtk+-2.0

and verify that it prints out something reasonable. Run:

    gtk-demo

and verify that it works.

 

To use the MS-Windows theme engine, create a file etc/gtk-2.0/gtkrc

containing the line:

gtk-theme-name = "MS-Windows"

2. Visual Studio 2008中搭建GTK+开发环境

1.http://www.gtk.org/download-windows.html上下载All-in-one bundles包,目前有2.162.22。下载完后解压到一个任意的目录中,如“D:\Environment\gtk”。

2.系统环境变量配置:我的电脑 ->属性->高级属性->环境变量->系统变量->Path,在Path值的最后添加“;D:\Environment\gtk\bin”。

3.设置VS2008编译环境

1)设置包含文件目录:工具->选项->项目和解决方案->VC++目录->显示一下内容的目录->包含文件,添加GTK目录include文件夹和include文件夹里的所有一级文件夹,共12项。还有lib文件夹的子文件夹里面的两个include文件夹,如下图所示。

2)转到库文件视图,添加GTK目录的Lib文件夹。

4.新建C++的空项目,在项目->项目属性->配置属性->链接器->附加依赖项中添加:

glib-2.0.lib gtk-win32-2.0.lib gdk-win32-2.0.lib gobject-2.0.lib gdk_pixbuf-2.0.lib gthread-2.0.lib gmodule-2.0.lib pango-1.0.lib intl.lib

5.测试:新建CPP文件,写入如下代码,可以正常运行则配置成功。

#include  

int main(int argc, char** argv) 

        GtkWidget* window; 

        gtk_init(&argc, &argv); 

        window = gtk_window_new(GTK_WINDOW_TOPLEVEL); 

        g_signal_connect(GTK_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL); 

        gtk_widget_show(window); 

        gtk_main(); 

        return 0; 

}

参考文章

http://blog.csdn.net/zfpnuc/archive/2010/06/04/5646735.aspx

http://www.programmersheaven.com/article/105521-Visual+Studio+2008+configuration+for+GTK%2B+GUI+development/info.aspx

3.开发中字体问题

在程序运行的时候遇到如下警告时:

 

(GTKTest01.exe:4876): Pango-WARNING **: couldn't load font "微软雅黑 Not-Rotated

 9", falling back to "Sans Not-Rotated 9", expect ugly output.

 

(GTKTest01.exe:4876): Pango-WARNING **: couldn't load font "微软雅黑 9", falling

 back to "Sans 9", expect ugly output.

 

这所代表的意思是系统加载系统默认的字体格式时,我们的gtk程序无法识别。

如在第一部分所说gtk程序开发时加载MS-Windows theme engine。所以我们要人为改变它的gtk程序运行时所用的字体格式。

C:\gtk\share\themes\MS-Windows\gtk-2.0找到gtkrc文件,在文件末尾加上如下内容:

style "user-font"

{

         font_name="Simsun 10"

}

widget_class "*"style"user-font"

这样我们就为gtk程序指定了字体。

4.实例学习

GTK2.0+学习

图1.第一个例子

对于以上类子,我们首先要介绍下gtk窗口的构成结构:

Windowà GtkAccelGroupàvbox,hbox…..(布局)àscrolledgroupà各种控件。

注意box的添加控件方法是gtk_box_pack_start.

而对于普通的容器添加使用gtk_container_add.

需要特别介绍的是menu的使用:

MenubaràmenuItemàmenuàmenuItem

GTK2.0+学习

图2.menu

 

而从menuItem加到menumenubar中,采用gtk_menu_shell_appen方法,而menumenuItem中采用gtk_menu_item_set_submenu方法。

 

然后就是对于事件的使用,采用g_signal_connect.而对于函数的参数传递,有待继续学习。

5.存在问题

1.事件处理参数传递

2.头文件xxx.h的处理作用

3.GtkTextView可写,在上加右击事件,增加弹出菜单之后的可写性。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Learn to completely uninstall pip and use Python more efficiently Learn to completely uninstall pip and use Python more efficiently Jan 16, 2024 am 09:01 AM

No more need for pip? Come and learn how to uninstall pip effectively! Introduction: pip is one of Python's package management tools, which can easily install, upgrade and uninstall Python packages. However, sometimes we may need to uninstall pip, perhaps because we wish to use another package management tool, or because we need to completely clear the Python environment. This article will explain how to uninstall pip efficiently and provide specific code examples. 1. How to uninstall pip The following will introduce two common methods of uninstalling pip.

A deep dive into matplotlib's colormap A deep dive into matplotlib's colormap Jan 09, 2024 pm 03:51 PM

To learn more about the matplotlib color table, you need specific code examples 1. Introduction matplotlib is a powerful Python drawing library. It provides a rich set of drawing functions and tools that can be used to create various types of charts. The colormap (colormap) is an important concept in matplotlib, which determines the color scheme of the chart. In-depth study of the matplotlib color table will help us better master the drawing functions of matplotlib and make drawings more convenient.

Getting Started with Pygame: Comprehensive Installation and Configuration Tutorial Getting Started with Pygame: Comprehensive Installation and Configuration Tutorial Feb 19, 2024 pm 10:10 PM

Learn Pygame from scratch: complete installation and configuration tutorial, specific code examples required Introduction: Pygame is an open source game development library developed using the Python programming language. It provides a wealth of functions and tools, allowing developers to easily create a variety of type of game. This article will help you learn Pygame from scratch, and provide a complete installation and configuration tutorial, as well as specific code examples to get you started quickly. Part One: Installing Python and Pygame First, make sure you have

Revealing the appeal of C language: Uncovering the potential of programmers Revealing the appeal of C language: Uncovering the potential of programmers Feb 24, 2024 pm 11:21 PM

The Charm of Learning C Language: Unlocking the Potential of Programmers With the continuous development of technology, computer programming has become a field that has attracted much attention. Among many programming languages, C language has always been loved by programmers. Its simplicity, efficiency and wide application make learning C language the first step for many people to enter the field of programming. This article will discuss the charm of learning C language and how to unlock the potential of programmers by learning C language. First of all, the charm of learning C language lies in its simplicity. Compared with other programming languages, C language

Let's learn how to input the root number in Word together Let's learn how to input the root number in Word together Mar 19, 2024 pm 08:52 PM

When editing text content in Word, you sometimes need to enter formula symbols. Some guys don’t know how to input the root number in Word, so Xiaomian asked me to share with my friends a tutorial on how to input the root number in Word. Hope it helps my friends. First, open the Word software on your computer, then open the file you want to edit, and move the cursor to the location where you need to insert the root sign, refer to the picture example below. 2. Select [Insert], and then select [Formula] in the symbol. As shown in the red circle in the picture below: 3. Then select [Insert New Formula] below. As shown in the red circle in the picture below: 4. Select [Radical Formula], and then select the appropriate root sign. As shown in the red circle in the picture below:

Learn the main function in Go language from scratch Learn the main function in Go language from scratch Mar 27, 2024 pm 05:03 PM

Title: Learn the main function in Go language from scratch. As a simple and efficient programming language, Go language is favored by developers. In the Go language, the main function is an entry function, and every Go program must contain the main function as the entry point of the program. This article will introduce how to learn the main function in Go language from scratch and provide specific code examples. 1. First, we need to install the Go language development environment. You can go to the official website (https://golang.org

Learn the strconv.Atoi function in the Go language documentation to convert strings to integers Learn the strconv.Atoi function in the Go language documentation to convert strings to integers Nov 03, 2023 am 08:55 AM

Learn the strconv.Atoi function in the Go language documentation to convert strings to integers. The Go language is a powerful and flexible programming language. The strconv package in its standard library provides the function of string conversion. In this post, we will learn how to convert string to integer using strconv.Atoi function. First, we need to understand the purpose and declaration of the strconv.Atoi function. The description of the function in the document is as follows: funcAtoi(sstring)(i

Quickly learn pip installation and master the skills from scratch Quickly learn pip installation and master the skills from scratch Jan 16, 2024 am 10:30 AM

Learn pip installation from scratch and quickly master the skills. Specific code examples are required. Overview: pip is a Python package management tool that can easily install, upgrade and manage Python packages. For Python developers, it is very important to master the skills of using pip. This article will introduce the installation method of pip from scratch, and give some practical tips and specific code examples to help readers quickly master the use of pip. 1. Install pip Before using pip, you first need to install pip. pip

See all articles