您的位置:时时app平台注册网站 > 编程知识 > [python] 改善Tkinter 的暗中认可Logo【时时app平台注

[python] 改善Tkinter 的暗中认可Logo【时时app平台注

2019-10-30 04:37

 

线程1修改a==0
线程1修改a==1
线程1修改a==2
线程1修改a==3
线程1修改a==4
线程2修改a==0
线程1修改a==5
线程1修改a==6
线程1修改a==7
线程1修改a==8
线程1修改a==9
线程2修改a==1
线程2修改a==2
线程2修改a==3
线程2修改a==4
线程2修改a==5
线程2修改a==6
线程2修改a==7
线程2修改a==8
线程2修改a==9

管住校订

阅读: 690131


现行反革命,假定你早就完全调整了暂存区的概念。下边,大家要切磋的正是,为啥Git比其他版本调节系统规划得呱呱叫,因为Git追踪并管理的是改善,而非文件。

您会问,什么是改进?比方你新扩大了生龙活虎行,那就是三个改变,删除了生机勃勃行,也是贰个改良,修改了某些字符,也是叁个退换,删了一些又加了大器晚成部分,也是三个校正,以致创办一个新文件,也算多少个改换。

为何说Git管理的是修改,并非文本呢?大家依旧做尝试。第一步,对readme.txt做一个改变,比如加生龙活虎行内容:

$ cat readme.txt
Git is a distributed version control system.
Git is free software distributed under the GPL.
Git has a mutable index called stage.
Git tracks changes.

然后,添加:

$ git add readme.txt
$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   readme.txt
#

然后,再修改readme.txt:

$ cat readme.txt 
Git is a distributed version control system.
Git is free software distributed under the GPL.
Git has a mutable index called stage.
Git tracks changes of files.

提交:

$ git commit -m "git tracks changes"
[master d4f25b6] git tracks changes
 1 file changed, 1 insertion( )

交给后,再看看动静:

$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   readme.txt
#
no changes added to commit (use "git add" and/or "git commit -a")

率先次改正 -> git add -> 第叁遍改正 -> git commit

,Git管理的是纠正,当你用git add指令后,在专门的学业区的首回修改被归入暂存区,计划付出,不过,在专门的学问区的第三遍改革并不曾放入暂存区,所以,git commit只担任把暂存区的改正提交了,也正是首先次的改变被提交了,第3回的修正不会被交付。

提交后,用git diff HEAD -- readme.txt指令可以查看专门的学问区和版本Curry面最新版本的分别:

$ git diff HEAD -- readme.txt 
diff --git a/readme.txt b/readme.txt
index 76d770f..a9c5755 100644
--- a/readme.txt
    b/readme.txt
@@ -1,4  1,4 @@
 Git is a distributed version control system.
 Git is free software distributed under the GPL.
 Git has a mutable index called stage.
-Git tracks changes.
 Git tracks changes of files.

 时时app平台注册网站 1

可以看到当一个线程运行完毕之后才运行第二个线程

Git管理的是修改

先是步,对readme.txt做二个校勘,比方加生龙活虎行内容:

cat readme.txt
Git is a distributed version control system.
Git is free software distributed under the GPL.
Git has a mutable index called stage.
Git tracks changes. 

然后,添加:

$ git add readme.txt
$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   readme.txt
#

时时app平台注册网站 2

package test.thread;

import java.io.IOException;

import org.junit.Test;

/*
 * 测试线程锁
 */
public class TestBlock {   //调用类

        public static void main(String[] args)  {
            TestBlock test = new TestBlock();
            MyTest thread1 = test.new MyTest(test);
            thread1.setName("1");
            MyTest thread2 = test.new MyTest(test);
            thread2.setName("2");
            thread1.start();
            thread2.start();
        }  
    /*
     * 测试同步
     */
    class MyTest extends Thread{
        private Object o;

        public  MyTest(Object o){
            this.o=o;
        }

        @Override
        public void run() {
            // TODO Auto-generated method stub
            synchronized (this) {  //this 指代当时类 也就是MyTest,两个线程同时调用同一个类方法。就是两个线程对两个实例的各自上锁。互相不阻塞

try { for(int a=0;a<10;a  ){ System.out.println("线程" MyTest.currentThread().getName() "修改a==" a); //MyTest.yield();  } } catch (Exception e) { // TODO: handle exception  } } } } }

返回的结果:

小结

  • git add (文件名/*)把代码增加到工作区中(暂存区)
  • git commit -am "message"交付到版本库

缘何 Git 比其他版本调整系统规划得可以,因为 Git 跟踪并保管的是改进,而非文件。 git commit 只担任把暂存区的改善提交了。 每趟改过,如果不 add 到暂存区,那就不会参与到 commit 中。 重要注意上面八个指令

git diff    #是工作区(work dict)和暂存区(stage)的比较
git diff --cached    #是暂存区(stage)和分支(master)的比较
git diff HEAD  #查看工作区和版本库里面最新版本的区别

在乎左上角的Logo为革命的Tk字样

 

处理改革

阅读: 690131


现行反革命,假定你已经完全调整了暂存区的定义。上边,大家要研商的正是,为何Git比任何版本调节系统规划得形形色色,因为Git追踪并拘系的是改进,而非文件。

您会问,什么是修正?譬喻您新扩充了后生可畏行,那正是贰个更改,删除了风流浪漫行,也是一个改造,校勘了一点字符,也是一个修正,删了一些又加了部分,也是贰个改造,以至成立多少个新文件,也算四个改革。

何以说Git管理的是订正,并非文件呢?大家照旧做尝试。第一步,对readme.txt做二个改动,比如加生机勃勃行内容:

$ cat readme.txt
Git is a distributed version control system.
Git is free software distributed under the GPL.
Git has a mutable index called stage.
Git tracks changes.

然后,添加:

$ git add readme.txt
$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   readme.txt
#

然后,再修改readme.txt:

$ cat readme.txt 
Git is a distributed version control system.
Git is free software distributed under the GPL.
Git has a mutable index called stage.
Git tracks changes of files.

提交:

$ git commit -m "git tracks changes"
[master d4f25b6] git tracks changes
 1 file changed, 1 insertion( )

付出后,再看看动静:

$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   readme.txt
#
no changes added to commit (use "git add" and/or "git commit -a")

哎呀,怎么第贰次的修改未有被提交?

别激动,大家想起一下操作进度:

率先次改过 -> git add -> 第一回匡正 -> git commit

你看,大家前面讲了,Git管理的是修改,当你用git add命令后,在工作区的首先次修改被放入暂存区,希图交付,可是,在工作区的第一次改过并从未放入暂存区,所以,git commit只担当把暂存区的更改提交了,也正是率先次的改进被交付了,第三遍的更换不会被交给。

提交后,用git diff HEAD -- readme.txt一声令下能够查阅工作区和版本Curry面最新版本的界别:

$ git diff HEAD -- readme.txt 
diff --git a/readme.txt b/readme.txt
index 76d770f..a9c5755 100644
--- a/readme.txt
    b/readme.txt
@@ -1,4  1,4 @@
 Git is a distributed version control system.
 Git is free software distributed under the GPL.
 Git has a mutable index called stage.
-Git tracks changes.
 Git tracks changes of files.

看得出,第三遍纠正确实没有被提交。

那怎么提交第一回改正呢?你能够持续git addgit commit,也可以别发急提交第一次改良,先git add第三次改善,再git commit,就一定于把一遍更改合併后一块提交了:

首先次修改 -> git add -> 第三次校正 -> git add -> git commit


先上二个不更改的样式,如下:

 

import easygui as g
from Tkinter import *
tk = Tk()

tk.iconbitmap(default = r'C:UsersxxooDownloadsbitbug_favicon.ico')

g.msgbox("hello","hi")

     

 

 

  

2.synchronized(this)

修改后:

1.synchronized(object)

呈现如下:

线程1修改a==0
线程1修改a==1
线程1修改a==2
线程1修改a==3
线程1修改a==4
线程1修改a==5
线程1修改a==6
线程1修改a==7
线程1修改a==8
线程1修改a==9
线程2修改a==0
线程2修改a==1
线程2修改a==2
线程2修改a==3
线程2修改a==4
线程2修改a==5
线程2修改a==6
线程2修改a==7
线程2修改a==8
线程2修改a==9

 

package test.thread;

import java.io.IOException;

import org.junit.Test;

/*
 * 测试线程锁
 */
public class TestBlock {

        public static void main(String[] args)  {
            TestBlock test = new TestBlock();
            MyTest thread1 = test.new MyTest(test);
            thread1.setName("1");
            MyTest thread2 = test.new MyTest(test);
            thread2.setName("2");
            thread1.start();
            thread2.start();
        }  
    /*
     * 测试同步
     */
    class MyTest extends Thread{
        private Object o;

        public  MyTest(Object o){
            this.o=o;
        }

        @Override
        public void run() {
            // TODO Auto-generated method stub
            synchronized (o) {  //这个o是test对象的实例 ,对类对象实例进行加锁,当线程调用一个实例运行的,另外的线程调用这个实例时候阻塞,达到上锁的目的
                try {
                    for(int a=0;a<3;a  ){
                        System.out.println("线程" MyTest.currentThread().getName() "修改a==" a);
                        //MyTest.yield();
                    }
                } catch (Exception e) {
                    // TODO: handle exception
                }

            }
        }

    }    

}

返回的结果:
  ·      
import easygui as g

g.msgbox("hello","hi")
 

本文由时时app平台注册网站发布于编程知识,转载请注明出处:[python] 改善Tkinter 的暗中认可Logo【时时app平台注

关键词: