会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132358个问题
JAVA 全系列/第二阶段:JAVA 基础深化和提高/XML 技术(旧) 38627楼
JAVA 全系列/预科阶段:职业规划/学习方法/就业和找工作需要注意事项 38628楼
Python 全系列/第三阶段:Python 网络与并发编程/网络通信 38629楼
JAVA 全系列/(旧的隐藏)第二十一阶段:百战商城项目(Spring Cloud最新架构)/百战商城项目 38631楼

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>window对象</title>
</head>
<body>
    <button>跨域传输</button>
    <script>
        // open('http://www.baidu.com');
        // close();
        // var but =document.querySelector('button');
        // but.onclick=function(){
        //     var iframe = document.createElement('iframe');
        //     iframe.src='name.html';
        //     iframe.style.display='none';
        //     document.body.appendChild(iframe);
        //     iframe.onload=function(eve){
        //         var iframeWindowName = eve.target.contentWindow.name;
        //         console.log(iframeWindowName);
        //     }
        // }
        var but= document.querySelector('button');
        but.onclick=function(){
       var iframe= document.createElement('iframe');
        iframe.src='name.html';//加载保存了信息的页面
        iframe.style.display='none';
        document.body.appendChild(iframe);
        //当iframe加载完毕,意味着window.name的内容已经被赋予完毕
        iframe.onload=function(eve){
            var iframeWindowName=eve.target.contentWindow.name;
           // console.log( iframeWindowName);
            eval(iframeWindowName);
            console.log(num);
        }
    }

    </script>
</body>
</html>

跟着老师的代码敲的,无奈报错,于是把老师的代码拿过来 仍然报错,如图

image.png

WEB前端全系列/第二阶段:JavaScript编程模块/面向对象编程 38632楼
JAVA 全系列/第一阶段:JAVA 快速入门/变量、数据类型、运算符 38635楼

package com.itbaizhan;
//测试数组的三个类型的初始化
public class Test02 {
    public static void main(String[] args) {

        //静态初始化
        int[] s = {1, 2, 3, 4, 5, 6, 7, 8};// 静态初始化基本类型数组;
        //相当于 int[] = s; s = new int[8];
        System.out.println(s[1]);
        Man[] men = {new Man(1, 22), new Man(2, 33)};// 静态初始化引用类型数组;
        System.out.println(men[1].getAge());

        /**动态初始化*/
        //基本数据类型的动态初始化
        int[] a;
        a = new int[10];
        a[0] = 1;
        a[1] = 2;
        System.out.println(a[0]);
        System.out.println(a[1]);
        //引用数据类型的动态初始化
        Animal[] animal;
        animal = new Animal[10];
        Animal a1 = new Animal(1,1);
        Animal a2 = new Animal(1002,21);
        animal[0] = a1;
        System.out.println(animal[0]);
    }

    class Animal{

        private int id;
        private   int age;

        public Animal(int id,int age){
            super();
            this.id = id;
            this.age = age;
        }


        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }


    }
}

老师这是啥情况

JAVA 全系列/第一阶段:JAVA 快速入门/数组和数据存储 38636楼
毕设项目/第一阶段:各种开发环境的使用/JDK的安装 38637楼

#encoding=utf-8

from tkinter import *
from tkinter.colorchooser import *
from tkinter.filedialog import *

class Application(Frame):
    def __init__(self, master = None):
        super().__init__(master)
        self.master = master
        self.pack()
        self.createWidget()
    def createWidget(self):
        # 创建主菜单栏
        menubar = Menu(root)

        # 创建子菜单
        menuFile = Menu(menubar)
        menuEdit = Menu(menubar)
        menuHelp = Menu(menubar)

        # 将子菜单加入到主菜单栏
        menubar.add_cascade(label='文件(F)', menu=menuFile)
        menubar.add_cascade(label='编辑(E)', menu=menuEdit)
        menubar.add_cascade(label='帮助(H)', menu=menuHelp)

        # 添加菜单项
        menuFile.add_command(label='新建', accelerator='ctrl + n', command=self.test)
        menuFile.add_command(label='打开', accelerator='ctrl + o', command=self.test)
        menuFile.add_command(label='保存', accelerator='ctrl + s', command=self.test)
        menuFile.add_separator()  # 添加分割线
        menuFile.add_command(label='退出', accelerator='ctrl + q', command=self.test)

        # 将主菜单栏加到跟窗口
        root['menu'] = menubar

        # 创建上下文菜单
        menubar2 = Menu(root)
        menubar2.add_command(label='颜色', command = self.openAskColor)

        menuedit = Menu(menubar2, tearoff = 0)
        menuedit.add_command(label='剪切')
        menuedit.add_command(label='复制')
        menuedit.add_command(label='粘贴')

        menubar2.add_cascade(label='编辑', menu=menuedit)

        # 编辑区
        w1 = Text(root, width=50, height=30)
        w1.pack()
        w1.bind('<Button-3>', text)
    def test(self):
        pass

    def openAskColor(self):
        s1 = askcolor(color='red', title='选择背景色')
        root.config(bg=s1[1])

    def test1(event):
        # 菜单在鼠标右键单击的坐标处显示
        menubar2.post(event.x_root, event.y_root)


if __name__ == "__main__":
    root = Tk()
    root.title('my window');root.geometry('450x300')
    app = Application(master = root)
    root.mainloop()

老师:问题很多,视频七分钟,百度两小时

  1. 如图,菜单栏虚线可以点击,并且点击后新弹出个窗口

image.png

2.这些地方是调用组件么。组件第一个字母不都是大写

image.png


3.我这里总是显示这样的,不知道为什么

image.png

Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 38638楼
JAVA 全系列/第八阶段:Linux入门到实战/Git 38639楼
Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 38640楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637