首页 \ 问答 \ 父窗口中的中心动态大小窗口(Center dynamic size window in parent window)

父窗口中的中心动态大小窗口(Center dynamic size window in parent window)

问题

由于子窗口动态大小,属性WindowStartupLocation不能很好地工作。 它将子窗口置于中心,但在此之后,子窗口会改变其大小并开始从主窗口的底部“弹出”。

考虑到子窗口具有动态大小,如何将父窗口的子窗口放在中心?

代码示例:
var window = new WindowDialog(MainWindow, "Title", new DialogAgent(), false)
            {
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
                SizeToContent = SizeToContent.Height,
                ShowInTaskbar = false
            };

PROBLEM

Because of child window dynamic size, the property WindowStartupLocation is not working well enough. It puts the child window in center, but after that, child window changes its size and starts to "pop out" from the bottom of the main window.

QUESTION

How to put the child window of the parent window in the center, taking into account that the child window has a dynamic size?

Code example:
var window = new WindowDialog(MainWindow, "Title", new DialogAgent(), false)
            {
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
                SizeToContent = SizeToContent.Height,
                ShowInTaskbar = false
            };

原文:https://stackoverflow.com/questions/43799964
更新时间:2023-12-01 20:12

最满意答案

使用参数memory = 'mycachedir'设置缓存目录,然后如果设置compute_full_tree=True ,当您重新运行n_clusters不同值时,它将使用缓存树而不是每次重新计算。 为了给您一个如何使用sklearn的gridsearch API执行此操作的示例:

from sklearn.cluster import AgglomerativeClustering
from sklearn.grid_search import GridSearchCV

ac = AgglomerativeClustering(memory='mycachedir', 
                             compute_full_tree=True)
classifier = GridSearchCV(ac, 
                          {n_clusters: range(2,6)}, 
                          scoring = 'adjusted_rand_score', 
                          n_jobs=-1, verbose=2)
classifier.fit(X,y)

You set a cacheing directory with the paramater memory = 'mycachedir' and then if you set compute_full_tree=True, when you rerun fit with different values of n_clusters, it will used the cached tree rather than recomputing each time. To give you an example of how to do this with sklearn's gridsearch API:

from sklearn.cluster import AgglomerativeClustering
from sklearn.grid_search import GridSearchCV

ac = AgglomerativeClustering(memory='mycachedir', 
                             compute_full_tree=True)
classifier = GridSearchCV(ac, 
                          {n_clusters: range(2,6)}, 
                          scoring = 'adjusted_rand_score', 
                          n_jobs=-1, verbose=2)
classifier.fit(X,y)

相关问答

更多
  • K-Means聚类器需要一个2D数组,每一行都是一个数据点,也可以是一维的。 在您的情况下,您必须将pandas列重塑为具有len(data)行和1列的矩阵。 请参阅下面的一个有效示例: from sklearn.cluster import KMeans import pandas as pd data = {'one': [1., 2., 3., 4., 3., 2., 1.], 'two': [4., 3., 2., 1., 2., 3., 4.]} data = pd.DataFrame(data ...
  • 您正在寻找的是在scipy.cluster.hierarchy中实现的,请参见此处 。 所以你可以这样做: from scipy.cluster.hierarchy import linkage, fcluster y_pred = fcluster(linkage(matrix), t, criterion='distance') # or more direct way from scipy.cluster.hierarchy import fclusterdata y_pred = fclust ...
  • 您要做的不再是聚类分析 。 它类似,但不是聚类。 您正在尝试对数据进行分段 ,即您实际上具有给定的序列并寻找分割它的好点。 在聚类分析中通常的思维方式中,您有许多单独的项目,并且您希望收集这些项目以便聚合附近的对象; 以某种方式,它们可能是也可能不是连续的。 真的,不是试图破解聚类算法来实现你的目标,而是从你的起点开始更有意义,并且可能“重用”以前在聚类中使用的一些想法。 原因不仅仅是技术问题,还有直觉问题 。 What you are trying to do is no longer cluster-a ...
  • 这取决于你想测试什么 。 在测试您自己的已知算法实现时,您可能想要将结果与已知良好实现的结果进行比较。 分层聚类很难在质量方面进行测试,因为它是分层的。 兰德指数等常用指标只适用于严格划分。 您可以从层次聚类中获得严格的分区,但是您需要修复要切割的高度。 It depends on what you want to test against. When testing your own implementation of a known algorithm, you might want to compar ...
  • 如果您想要在特定级别切割树,请使用: fl = fcluster(cl,numclust,criterion='maxclust') 其中cl是连接方法的输出, numclust是您想要获取的群集的数量。 If you want to cut the tree at a specific level, then use: fl = fcluster(cl,numclust,criterion='maxclust') where cl is the output of your linkage metho ...
  • 回答你的问题: 不,此信息在链接后不可用,至少根据官方Python文档。 最接近的一对点问题是计算几何问题,并且可以通过递归分治算法在对数时间内求解(注意穷举搜索是二次的)。 有关更多信息,请参阅此Wikipedia 文章 。 另请参阅Shamos和Hoey撰写的这篇论文 。 请注意,问题的原始表述仅涉及一组点。 但是,适应两套很简单; 您可能会发现此讨论很有帮助。 To answer your questions: No, this information is not available after l ...
  • library(WeightedCluster) (agnesRange <- wcKMedRange(rubinius.dist, 2:10)) plot(agnesRange, stat = c("ASW", "HG", "PBC"), lwd = 5) 这将给出多个索引,用于查找理想数量的聚类以及图形。 有关索引的更多信息可以在这里找到(在集群质量下): http : //mephisto.unige.ch/weightedcluster/ library(WeightedCluster) ...
  • 是的,你可以用sklearn 。 你需要设置: affinity='precomputed' ,使用距离矩阵 linkage='complete'或'average' ,因为默认链接(Ward)仅适用于坐标输入。 利用预先计算的亲和力,输入矩阵被解释为观察之间的距离矩阵。 以下代码 from sklearn.cluster import AgglomerativeClustering data_matrix = [[0,0.8,0.9],[0.8,0,0.2],[0.9,0.2,0]] model = Ag ...
  • 使用参数memory = 'mycachedir'设置缓存目录,然后如果设置compute_full_tree=True ,当您重新运行n_clusters不同值时,它将使用缓存树而不是每次重新计算。 为了给您一个如何使用sklearn的gridsearch API执行此操作的示例: from sklearn.cluster import AgglomerativeClustering from sklearn.grid_search import GridSearchCV ac = Agglomerat ...
  • 将连接矩阵传递给sklearn.cluster.AgglomerativeClustering ,必须连接矩阵中的所有点。 凝聚聚类创建一个层次结构,其中所有点都迭代地组合在一起,因此不能存在孤立的聚类。 连接矩阵可用于“关闭”欧几里德空间附近的点的连接,但远离另一个度量(请参阅用户指南中的果冻卷示例)。 想到这一点的另一种方法是你的点必须形成一个不相交的图形,你所能做的就是关闭节点之间的边缘。 这个警告: UserWarning:连接矩阵的连接组件数为7> 1.完成它以避免提前停止树。 连接,n_comp ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。