2021-07-10

云计算课设代码

aaa.py

## #coding:utf-8
import subprocess
import numpy as np
import os
array1 = np.load("./array1.npy")
array2 = np.load("./array2.npy")
res_row = array1.shape[0]
res_col = array2.shape[1]
res = np.zeros((res_row, res_col))
cac = np.zeros((res_row, res_col))
np.save("./res.npy", res)
np.save("./cac.npy", cac)
ss=np.array([array1.shape[0],array1.shape[1]])
np.save("./shape.npy",ss)`在这里插入代码片`
while(np.all(cac)==False):
    IP=[]
    UIP=[]
    ta=[]
    for line in open("mpi_config.txt"):
        line = line.replace("\n", '')
        line = line.split(":")
        IP.append([line[0],line[1]])
    for ip,co in IP:
        if (subprocess.call('ping '+ip+' -c5', shell=True)):
            UIP.append([ip,co])
	    ta.append(ip)
        else:
            continue
    f = open("mpi_config_new.txt", "a")
    print("open")
    for i in range(len(IP)):
	if (IP[i][0] not in ta):
            f.write("{}:{}\n".format(IP[i][0], IP[i][1]))
    	print("iiiiii")
    f.close()
    os.rename('mpi_config.txt', 'mpi_config.bak')
    os.rename('mpi_config_new.txt', 'mpi_config.txt')
    os.remove('mpi_config.bak')
    if (subprocess.call("mpiexec -n 3 -f ./mpi_config.txt python ./bbb.py", shell=True)):
        print("unsuccess!restart!")
        cac=np.load("./cac.npy")
    else:
        print("success!")
        break
# -*- coding: utf-8 -*-
from mpi4py import MPI
import  numpy as np


comm = MPI.COMM_WORLD
size = comm.Get_size()
rank = comm.Get_rank()

def check(cac):
    row=cac.shape[0]
    col=cac.shape[1]
    miss=[]
    for i in range(row):
        for j in range(col):
           if(cac[i][j]==0):
               miss.append([i,j])
    return miss

if(rank==0):
    array1=np.load("./array1.npy")
    array2=np.load("./array2.npy")
    cac = np.load("./cac.npy")
    res = np.load("./res.npy")
    miss=check(cac)
    count=0
    miss_number=len(miss)
    print(miss_number)
    np.save("./miss_number.npy",np.array([miss_number]))
    cor = [[] for i in range(size)]
    for i in range(1,miss_number+1):#这样就会从别的电脑开始而不是0号,要不然就感觉怪怪的不是全并行了
        if (count == size):
            count = 0
            for ii in range(1, size):
                rec = comm.irecv(source=ii, tag=100 + ii)
                data = rec.wait()
		print(data)
                print(cor[ii][0])
		print(cor[ii][0])
		res[cor[ii][0]][cor[ii][1]] = data
                cac[cor[ii][0]][cor[ii][1]] = 1
            res[cor[0][0]][cor[0][1]] = result
            cac[cor[0][0]][cor[0][1]] = 1
            np.save("./res.npy", res)
            np.save("./cac.npy", cac)
	    print('sdfsdfsdfsfdsdf')
	print(i)
        mid = miss[i-1]
        row_data = list(array1[mid[0]])
        col_data = list(array2[:, mid[1]])
        data = np.array(row_data + col_data)
        cor[i%size] = mid
        if (i % size != 0):
            send = comm.Send([data, MPI.INT], dest=i % size, tag=11 + i % size)
            print(data)
        else:
            result=0
            for ij in range(len(row_data)):
                result+=row_data[ij]*col_data[ij]
	    print(result)
            #自己计算
        count += 1
    if(count!=0):
        for ii in range(1, count+1):
	    print(';;;;;;;;;;;;')
            rec = comm.irecv(source=ii, tag=100 + ii)
            data = rec.wait()
            print(data)
            print(cor[ii][0])
            print(cor[ii][0])
            res[cor[ii][0]][cor[ii][1]] = data
            cac[cor[ii][0]][cor[ii][1]] = 1
            np.save("./res.npy", res)
            np.save("./cac.npy", cac)


    #
    #
    # #用%来解决。
    # times=int(miss_number/size)+1
    # for t in range(times):
    # # while True:
    #     cor=[[] for i in range(size)]
    #     send_number=0
    #     for i in range(1,size):
    #         count+=1
    #         if(count>miss_number):
    #             break
    #         else:
    #             send_number +=1
    #             mid=miss[count-1]
    #             row_data=list(array1[mid[0]])
    #             col_data=list(array2[:,mid[1]])
    #             cor[i]=mid
    #             d]ave("./res.npy", res)
    #             send= comm.Send([data,MPI.INT], dest=i, tag=11+i)
    #             # send.wait()
    #     for i in range(1,size):
    #         send_number-=1
    #         if(send_number<0):
    #             break
    #         else:
    #             rec = comm.irecv(source=i, tag=100+i)
    #             data = rec.wait()
    #             res[cor[i][0]][cor[i][1]]=data
    #             cac[cor[i][0]][cor[i][1]]=data
    #     np.save("./res.npy",res)
    #     np.save("./cac.npy",cac)
    #     if (count > miss_number):
    #         break
    # np.save("./res.npy",res)
    # np.save("./cac.npy",cac)
else:

    miss_number=np.load("./miss_number.npy")
    miss_number=miss_number[0]
    ss=np.load("./shape.npy")
    count=0
    maxn=int(miss_number/size)
#    data = np.empty(ss[1] * 2, dtype="i")
    for i in range(1,miss_number+1):
        if(count==size):
            res=0
            for ii in range(ss[1]):
                res += data[ii] * data[ii +ss[1]]
 	    print(res)
	    for ii in range(1,size):
		if (rank==ii):
                    send = comm.isend(res, dest=0, tag=100 + ii)
#            send.wait()
            count=0

        if (rank == i%size and i<size*maxn+1):
            data = np.empty(ss[1] * 2, dtype="i")
            rec = comm.Recv([data, MPI.INT], source=0, tag=11 + i%size)
            print(data)
	    # for i in range(ss.shape[1] ):
            #     result += data[i] * data[i + ss.shape[1]]
        count+=1
    if(count!=0):	
#       res=0
#       for ii in range(ss[1]):
#           res += data[ii] * data[ii +ss[1]]
#        print(res)
 	#data = np.empty(ss[1] * 2, dtype="i")
        for ii in range(1,count+1):
            if (rank==ii):
        	data = np.empty(ss[1] * 2, dtype="i")	
                rec = comm.Recv([data, MPI.INT], source=0, tag=11 + i%size)
		res=0
		for ii in range(ss[1]):
            	    res += data[ii] * data[ii +ss[1]]
        	print('sdfsfsef',res)
	for ii in range(1,count+1):
            if (rank==ii):
                send = comm.isend(res, dest=0, tag=100 + ii)
		print('uuuuuuuuuuuu')
#            send.wait()

    # times=int(miss_number/size)
    # sy=miss_number%size
    # for t in range(times):
    #     for i in range(1,size):
    #         if (rank==i):
    #             data=np.array(cac.shape[0]*2,dtype=int)
    #             rec = comm.Recv([data,MPI.INT],source=0, tag=11+i)
    #             # data = rec.wait()
    #             result=0
    #             n=len(data)
    #             for i in range(int(n/2)):
    #                 result+=data[i]*data[i+int(n/2)]
    #             send = comm.isend(result, dest=0, tag=100+i)
    #             send.wait()
    # for i in range(1,sy+1):
    #     if(rank==i):
    #         data = np.array(cac.shape[0], dtype=int)
    #         rec = comm.Recv([data, MPI.INT], source=0, tag=11+i)
    #         # data = rec.wait()
    #         result = 0
    #         n = len(data)
    #         for i in range(int(n / 2)):
    #             result += data[i] * data[i + int(n / 2)]
    #         send = comm.isend(result, dest=0, tag=100+i)

可视化界面

import tkinter as tk
from tkinter import *
import tkinter.font as tkFont
from PIL import Image, ImageTk
import tkinter.messagebox
from tkinter import ttk
import docker
import random

def create_kvm(kvmlist):
    def addkvm():
	#创建kvm信息
        a = kvm()
        a.cpun =int(_cpun.get())
        a.ID =_id.get()
        a.IP = _IP.get()
        a.memory =int(_memory.get())
        kvmlist.append(a)
        base_url=_IP.get()+':2375'
        client = docker.DockerClient(base_url,use_ssh_client=True)
        network=client.networks.list(names=['cc'])
        name=a.ID
        num = range(0, 4)
        nums = random.sample(num, a.cpun)
        cpuns=str(nums[0])
        for i in range(1,len(nums)):
            cpuns=cpuns+','+str(nums[i])
        client.containers.run(image='cc',name=name,tty=True,privileged=True,stdin_open=True,detach=True,cpuset_cpus=cpuns,mem_limit=_memory.get()+'m')
        network[0].connect(name)
        createframe.destroy()
    createframe=tk.Toplevel()
    createframe.geometry("%dx%d" % (400, 300))  # 窗体尺寸
    screenwidth1 = createframe.winfo_screenwidth()
    screenheight1 = createframe.winfo_screenheight()
    width1, height1 = get_window_size(createframe)[:2]
    size1 = '%dx%d+%d+%d' % (width1, height1, (screenwidth1 - width1) / 2, (screenheight1 - height1) / 3)
    createframe.geometry(size1)# 将窗体移动到屏幕*
    #美观,填充间隔
    frame_seperator3 = tk.Frame(createframe, height=20, bg="whitesmoke")
    frame_seperator3.pack(fill=tk.X)
    frame_seperator1 = tk.Frame(createframe, width=20, bg='whitesmoke')
    frame_seperator1.pack(side=tk.RIGHT, fill=tk.Y)
    frame_seperator2 = tk.Frame(createframe, width=20, bg='whitesmoke')
    frame_seperator2.pack(side=tk.LEFT, fill=tk.Y)

    frame1 = tk.Frame(createframe, bg="white")
    frame1.pack(fill=tk.X)
    tk.Label(frame1, text="IP地址:        ", bg="white", fg='black', height=2,
             font=tkFont.Font(family="微软雅黑", size=8)).pack(side=tk.LEFT, padx=20, pady=10)
    _IP = tk.Entry(frame1, width=27)
    _IP.pack(side=tk.LEFT)

    frame2 = tk.Frame(createframe, bg="white")
    frame2.pack(fill=tk.X)
    tk.Label(frame2, text="虚拟机名称: ", bg="white", fg='black', height=2,
             font=tkFont.Font(family="微软雅黑", size=8)).pack(side=tk.LEFT, padx=20, pady=10)
    _id = tk.Entry(frame2, width=27)
    _id.pack(side=tk.LEFT)

    frame3 = tk.Frame(createframe, bg="white")
    frame3.pack(fill=tk.X)
    tk.Label(frame3, text="CPU个数:    ", bg="white", fg='black', height=2,
             font=tkFont.Font(family="微软雅黑", size=8)).pack(side=tk.LEFT, padx=20, pady=10)
    _cpun = tk.Entry(frame3, width=27)
    _cpun.pack(side=tk.LEFT)

    frame4 = tk.Frame(createframe, bg="white")
    frame4.pack(fill=tk.X)
    tk.Label(frame4, text="内存分配:    ", bg="white", fg='black', height=2,
             font=tkFont.Font(family="微软雅黑", size=8)).pack(side=tk.LEFT, padx=20, pady=10)
    _memory = tk.Entry(frame4, width=27)
    _memory.pack(side=tk.LEFT)

    frame5 = tk.Frame(createframe, bg="white")
    frame5.pack(fill=tk.X, )
    tk.Button(frame5, text='确认', width=10, height=1, bg='white', relief=GROOVE, command=addkvm).pack(
        side=tk.RIGHT, padx=10)

def delete_kvm(kvmlist):
    kvmlist=updatestats(kvmlist)
    def delekvm():
        temp=cmb.get()
        tp=a.index(temp)
        base_url = kvmlist[tp].IP
        client = docker.DockerClient(base_url, use_ssh_client=True)
        container=client.containers.get(client.containers.list(all=True,filters={'name':temp})[0].short_id)
        container.remove(force=True)
        kvmlist.pop(tp)
        deleframe.destroy()
    deleframe=tk.Toplevel()
    deleframe.geometry("%dx%d" % (400, 300))  # 窗体尺寸
    screenwidth1 = deleframe.winfo_screenwidth()
    screenheight1 = deleframe.winfo_screenheight()
    width1, height1 = get_window_size(deleframe)[:2]
    size1 = '%dx%d+%d+%d' % (width1, height1, (screenwidth1 - width1) / 2, (screenheight1 - height1) / 3)
    deleframe.geometry(size1)
    cmb = ttk.Combobox(deleframe)
    cmb.pack()
    a=[]
    for i in range(len(kvmlist)):
        a.append(kvmlist[i].ID)
    cmb['value'] = a
    tk.Button(deleframe, text='确认', width=10, height=1, bg='white', relief=GROOVE, command=delekvm).pack(
         side=tk.RIGHT, padx=10)


def open_kvm(kvmlist):
    kvmlist=updatestats(kvmlist)
    def openkvm():
        temp = cmb.get()
        tp = a.index(temp)
        base_url = kvmlist[tp].IP
        client = docker.DockerClient(base_url, use_ssh_client=True)
        container = client.containers.get(client.containers.list(all=True,filters={'name':kvmlist[tp].ID})[0].short_id)
        container.start()
        kvmlist[tp].stats='运行中'
        deleframe.destroy()
    deleframe = tk.Toplevel()
    deleframe.geometry("%dx%d" % (400, 300))  # 窗体尺寸
    screenwidth1 = deleframe.winfo_screenwidth()
    screenheight1 = deleframe.winfo_screenheight()
    width1, height1 = get_window_size(deleframe)[:2]
    size1 = '%dx%d+%d+%d' % (width1, height1, (screenwidth1 - width1) / 2, (screenheight1 - height1) / 3)
    deleframe.geometry(size1)
    cmb = ttk.Combobox(deleframe)
    cmb.pack()
    a = []
    for i in range(len(kvmlist)):
        if kvmlist[i].stats=='停止中':
            a.append(kvmlist[i].ID)
    cmb['value'] = a
    tk.Button(deleframe, text='确认', width=10, height=1, bg='white', relief=GROOVE, command=openkvm).pack(
        side=tk.RIGHT, padx=10)
    print(kvmlist)

def shutdown_kvm(kvmlist):
    kvmlist=updatestats(kvmlist)
    def stkvm():
        temp = cmb.get()
        tp = a.index(temp)
        base_url = kvmlist[tp].IP
        client = docker.DockerClient(base_url, use_ssh_client=True)
        container = client.containers.get(client.containers.list(all=True,filters={'name':kvmlist[tp].ID})[0].short_id)
        container.stop()
        kvmlist[tp].stats='停止中'
        deleframe.destroy()
    deleframe = tk.Toplevel()
    deleframe.geometry("%dx%d" % (400, 300))  # 窗体尺寸
    screenwidth1 = deleframe.winfo_screenwidth()
    screenheight1 = deleframe.winfo_screenheight()
    width1, height1 = get_window_size(deleframe)[:2]
    size1 = '%dx%d+%d+%d' % (width1, height1, (screenwidth1 - width1) / 2, (screenheight1 - height1) / 3)
    deleframe.geometry(size1)
    cmb = ttk.Combobox(deleframe)
    cmb.pack()
    a = []
    for i in range(len(kvmlist)):
        if kvmlist[i].stats == '运行中':
            a.append(kvmlist[i].ID)
    cmb['value'] = a
    tk.Button(deleframe, text='确认', width=10, height=1, bg='white', relief=GROOVE, command=stkvm).pack(
        side=tk.RIGHT, padx=10)

def get_window_size(win, update=True):
	""" 获得窗体的尺寸 """
	if update:
		win.update()
	return win.winfo_width(), win.winfo_height(), win.winfo_x(), win.winfo_y()

def read_me():
    tk.messagebox.askokcancel('使用指南','请按照提示输入相关参数以创建虚拟机\n通过左侧按钮管理你的虚拟机')

#虚拟机相关参数
class kvm:
    def __init__(self):
        self.ID = '';
        self.IP = '';
        self.cpun=0;
        self.cpu  = 0;
        self.memoryrate=0;
        self.memory= 0;
        self.stats='';

def showcpustate(parent,kvmlist,i):
    if kvmlist[i].stats=='运行中':
        frame= tk.Frame(parent, bg="white")
        tk.Label(frame, text="虚拟机名称: "+kvmlist[i].ID, bg="white", fg='black', height=2,
             font=tkFont.Font(family="微软雅黑", size=11, weight=tkFont.BOLD)).pack(side=tk.LEFT,padx=10, pady=5)
        tk.Label(frame, text="cpu数量: "+str(kvmlist[i].cpun), bg="white", fg='black', height=2,
             font=tkFont.Font(family="微软雅黑", size=11)).pack(side=tk.LEFT, padx=5)
        tk.Label(frame, text="内存总量: " + str(kvmlist[i].memory)+"M", bg="white", fg='black', height=2,
             font=tkFont.Font(family="微软雅黑", size=11)).pack(side=tk.LEFT, padx=5)
        tk.Label(frame, text="cpu使用率: " + str(kvmlist[i].cpu)+"%", bg="white", fg='black', height=2,
             font=tkFont.Font(family="微软雅黑", size=11)).pack(side=tk.LEFT, padx=5)
        tk.Label(frame, text="内存使用率: " + str(kvmlist[i].memoryrate)+"%", bg="white", fg='black', height=2,
             font=tkFont.Font(family="微软雅黑", size=11)).pack(side=tk.LEFT, padx=5)
        tk.Label(frame, text="状态: " +kvmlist[i].stats, bg="white", fg='black', height=2,
             font=tkFont.Font(family="微软雅黑", size=11)).pack(side=tk.LEFT, padx=5)
    else:
        frame= tk.Frame(parent, bg="white")
        tk.Label(frame, text="虚拟机名称: "+kvmlist[i].ID, bg="white", fg='black', height=2,
             font=tkFont.Font(family="微软雅黑", size=11, weight=tkFont.BOLD)).pack(side=tk.LEFT,padx=20, pady=5)
        tk.Label(frame, text="状态: " +kvmlist[i].stats, bg="white", fg='black', height=2,
             font=tkFont.Font(family="微软雅黑", size=11)).pack(side=tk.LEFT, padx=10)
    return frame

def updatecpu(parent,kvmlist):
    kvmlist=updatestats(kvmlist) 
    for widget in parent.winfo_children():
        widget.destroy()
    for i in range(len(kvmlist)):
        frame_name="frame"+str(i)
        frame_name=showcpustate(parent,kvmlist,i).pack(fill=tk.X)


def updatestats(kvmlist):
    kvmlist=[]
    netlink=['tcp://192.168.43.83:2375','tcp://192.168.43.179:2375']
    for d in range(2):
        client = docker.DockerClient(base_url=netlink[d], use_ssh_client=True)
        for i in range(len(client.containers.list(all=True))):
            container = client.containers.get(client.containers.list(all=True)[i].short_id)
            a = kvm()
            if container.status == 'running':
                a.stats = '运行中'
                mem_usage = container.stats(stream=False)['memory_stats']['usage']
                mem_limit = container.stats(stream=False)['memory_stats']['limit']
                returnval = round(float(mem_usage) / float(mem_limit) * 100, 2)
                system_use = container.stats(stream=False)['cpu_stats']['system_cpu_usage']
                total_use = container.stats(stream=False)['cpu_stats']['cpu_usage']['total_usage']
                cpu_count = len(container.stats(stream=False)['cpu_stats']['cpu_usage']['percpu_usage'])
                returncval = round((float(total_use) / float(system_use)) * cpu_count * 100.0, 2)
                name1 = container.stats(stream=False)['name']
                a.ID = name1.split('/')[1]
                a.cpu = returncval
                a.memory = round(mem_limit / 1024 / 1024, 3)
                a.memoryrate = returnval
                a.IP = netlink[d]
                cpun = 0
                for i in range(len(container.stats(stream=False)['cpu_stats']['cpu_usage']['percpu_usage'])):
                    if container.stats(stream=False)['cpu_stats']['cpu_usage']['percpu_usage'][i] != 0:
                        cpun = cpun + 1
                a.cpun = cpun
            else:
                a.stats = '停止中'
                name1 = container.stats(stream=False)['name']
                a.ID = name1.split('/')[1]
                a.IP = netlink[d]
            kvmlist.append(a)
    return kvmlist        
#主函数
if __name__ == '__main__':
    global kvmlist
    kvmlist=[]
    root=tk.Tk()
    root.geometry("%dx%d" % (1200, 800))  # 窗体尺寸
    screenwidth = root.winfo_screenwidth()
    screenheight = root.winfo_screenheight()
    width, height = get_window_size(root)[:2]
    size = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 3)
    root.geometry(size)# 将窗体移动到屏幕*
    root.title("虚拟机控制器")  # 窗体标题

    #上方标题
    frame_top = tk.Frame(root, bg="black")
    frame_top.pack(fill=tk.X)
    #设置标签相关内容
    tk.Label(frame_top, text="虚拟机管理系统", bg="black", fg='white', height=2,
             font=tkFont.Font(family="微软雅黑", size=16, weight=tkFont.BOLD)).pack(side=tk.LEFT, padx=10)
    tk.Label(frame_top, text="中国地质大学(武汉)", bg="black", fg='white', height=2,
             font=tkFont.Font(family="微软雅黑", size=12, weight=tkFont.NORMAL)).pack(side=tk.RIGHT, padx=20)
    #对图片进行按比例缩放处理
    lbl_image = tk.Label(frame_top, width=70, height=50)
    lbl_image.pack(side=tk.RIGHT)
    imgtop = Image.open(r'cug.jpg')
    w, h = imgtop.size
    height = 50
    width = 70
    img1 = imgtop.resize((width, height), Image.ANTIALIAS)
    tk_img = ImageTk.PhotoImage(img1)
    lbl_image.image = tk_img
    lbl_image.config(image=tk_img)

    #核心框架
    frame_main = tk.Frame(root, bg="whitesmoke")
    frame_main.propagate(False)
    frame_main.pack(expand=tk.YES, fill=tk.BOTH)

    frame_maintop = tk.Frame(frame_main, bg="white", height=80)
    frame_maintop.pack(fill=tk.X, padx=20, pady=10)
    imagetop = tk.Label(frame_maintop, width=180, height=60)
    imgmaintop = Image.open(r'kvm.jpg')
    w, h = imgmaintop.size
    width = 180
    height = 60
    img2 = imgmaintop.resize((width, height), Image.ANTIALIAS)
    _2img = ImageTk.PhotoImage(img2)
    imagetop.image = _2img
    imagetop.config(image=_2img)
    imagetop.pack(side=tk.LEFT, padx=10, pady=10)
    tk.Label(frame_maintop, text="Docker虚拟机管理器", bg="white", fg='black', height=4,
             font=tkFont.Font(family="微软雅黑", size=18, weight=tkFont.BOLD)).pack(side=tk.LEFT, padx=10)
    bu1=tk.Button(frame_maintop, text='使用指南', width=20, height=1,bg='white',relief=GROOVE,command=read_me).pack(side=tk.RIGHT, padx=10)

    frame_mainleft=tk.Frame(frame_main, width=180, bg="white")
    frame_mainleft.pack(side=tk.LEFT, fill=tk.Y, padx=30)
    tk.Label(frame_mainleft, text="管理中心", bg="white", fg='black', height=2,
             font=tkFont.Font(family="微软雅黑", size=16, weight=tkFont.BOLD)).pack(anchor=tk.W, padx=20, pady=5)
    bu2 = tk.Button(frame_mainleft, text='创建虚拟机', width=30, height=2, bg='white', relief=FLAT,
                    font=tkFont.Font(family="微软雅黑", size=12),command=lambda:create_kvm(kvmlist)).pack(padx=10,pady=5)
    bu3 = tk.Button(frame_mainleft, text='删除虚拟机', width=30, height=2, bg='white', relief=FLAT,
                    font=tkFont.Font(family="微软雅黑", size=12), command=lambda:delete_kvm(kvmlist)).pack(padx=10, pady=5)
    bu4 = tk.Button(frame_mainleft, text='开启虚拟机', width=30, height=2, bg='white', relief=FLAT,
                    font=tkFont.Font(family="微软雅黑", size=12), command=lambda:open_kvm(kvmlist)).pack(padx=10, pady=5)
    bu5 = tk.Button(frame_mainleft, text='关闭虚拟机', width=30, height=2, bg='white', relief=FLAT,
                    font=tkFont.Font(family="微软雅黑", size=12), command=lambda:shutdown_kvm(kvmlist)).pack(padx=10, pady=5)
    frame_mainleft.propagate(False)
    #左右分界
    frame_seperator1 = tk.Frame(frame_main, width=20, bg='whitesmoke')
    frame_seperator1.pack(side=tk.RIGHT, fill=tk.Y)

    frame_mainright = tk.Frame(frame_main, width=200, bg="white")
    frame_mainright.pack(side=tk.RIGHT, expand=tk.YES, fill=tk.BOTH)

    frame_mainrighttop = tk.Frame(frame_mainright, bg="white", height=80)
    frame_mainrighttop.pack(fill=tk.X, padx=20, pady=5)
    frame_mainrightbot= tk.Frame(frame_mainright, bg="white", height=80)
    frame_mainrightbot.pack(fill=tk.X, padx=20, pady=5)
    tk.Label(frame_mainrighttop, text="监控中心", bg="white", fg='black', height=2,
             font=tkFont.Font(family="微软雅黑", size=12, weight=tkFont.BOLD)).pack(side=LEFT,padx=20)
    bu6 = tk.Button(frame_mainrighttop, text='更新', width=10, height=1, bg='white', relief=GROOVE
                    , command=lambda:updatecpu(frame_mainrightbot,kvmlist))
    bu6.pack(side=RIGHT, padx=20)

    #填充间隔
    frame_seperator2=tk.Frame(frame_mainright, height=2, bg="whitesmoke")
    frame_seperator2.pack(fill=tk.X)

    #留白标签
    frame_empty = tk.Frame(root, height=10, bg="whitesmoke")
    frame_empty.pack(fill=tk.X)
    frame_empty.propagate(True)

    root.mainloop()
上一篇:安装vim插件


下一篇:有趣的python库-tkinter